Old Guy @ The Terminal Ep 2: Python Sucks!
Episodio 2! Oh yeah!
Esta es una charla relámpago que dí en la PyCon Argentina de 2018, es cortita y sencilla, ojalá les guste!
Episodio 2! Oh yeah!
Esta es una charla relámpago que dí en la PyCon Argentina de 2018, es cortita y sencilla, ojalá les guste!
Este es el primer (y por ahora único, obviamente) episodio de un nuevo canal de video llamado "Old Guy @ The Terminal" en el que muestro algunas cositas de Linux, programación, como se relacionan cosas actuales con cosas viejas y veremos qué más a medida que se me ocurran temas.
Nunca había hecho algo parecido, así que no sean muy duros conmigo ;-)
En este episodio vemos qué es una terminal, como se hace un programa para terminal y una terminal para el programa, porque por qué no.
En algún momento va a haber una versión en inglés (tal vez).
El código: en GitHub
I have some rather unusual holes in my education. I never, for example, learned much about electronics. It has always been a mistery, a thing other people knew about.
And then one day I ran into this gadget:
What is it? A volume knob for your PC. It plugs via USB and you can use it to turn volume up or down. I suppose if you press it it mutes audio or something.
It costs 50 dollars. 50 fucking dollars. For a dial.
Sure, it's pretty but how hard can it be?
So, I started looking at how to do it. Here's what I learned first:
The last item is important. When I was a kid in the 70s, electronics was a thing for wealthy kids. I was not wealthy. So, the possibility of doing this sort of thing? With cheap stuff? Sign me up!
So, I did what everyone does to learn stuff in 2019: I jumped into youtube and asked to be taught electronics. And a day later ... well, I know enough to break things and to implement this!
The goal is:
So, here is the BOM:
A second stage (once I have another Digispark) will involve making it nice, but for now let's make it work.
Here is the wiring, which is probably a pile of crap but works for me (sorry, don't want to learn how to do it properly).
Wiring between the Digispark and the KY-040:
P0 -> CLK
P1 -> SW
P2 -> DT
5V -> +
GND -> GND
I also connected KY-040's SW -> 1K resistor -> LED -> 5V
so the LED turns on when the button is pressed, but that's optional.
IMPORTANT NOTE In order for P1 to work properly, I needed to scratch off a connection to disable the onboard LED so, if that's a problem, you may be able to use P5 instead but P5 is disabled in the cheap Digispark clones. We can't use P3 and P4 because they are needed for USB. So, your choice.
So, here is all the wiring. If the image differs from my description, trust the image because it's working ;-)
Once you have everything wired, we need to work on the software side of things.
I used a couple of libraries:
I had to configure a global shortcut to enable/disable the michrophone. I used the F10 key and the command pulseaudio-ctl mute-input
but you figure out what you want to do.
I wrote a Sketch that does the following:
This way, if you want to mute, just click. If you want to talk, make sure you mute input when the session starts, then click-and-hold and while it's pressed the microphone is enabled. Nice, isn't it?
Does it work? Oh yeah! (No, the music is not coming from the PC, just look at the screen to see what changes) and sorry this video is so crappy.
And here's the code (which is my 1st arduino sketch, but I have been programming for a long time ;-)
#include "TrinketHidCombo.h" #include <SimpleRotary.h> // https://github.com/mprograms/SimpleRotary // Pin A, Pin B, Button Pin // Setting the button to 5 because this code handles it manually. SimpleRotary rotary(0, 2, 5); void setup() { TrinketHidCombo.begin(); pinMode(1, INPUT); } void loop() { static unsigned long time_pressed = 0; static byte ptt_flag = 0; byte i = rotary.rotate(); if (i == 1) { TrinketHidCombo.pressMultimediaKey(MMKEY_VOL_UP); } else if (i == 2) { TrinketHidCombo.pressMultimediaKey(MMKEY_VOL_DOWN); } int button = digitalRead(1); if (button == LOW) { // Yes, clicking the button makes it LOW if (time_pressed == 0) { // It's a new click time_pressed = millis(); } else { // Button has been pressed a while if ((millis() - time_pressed) > 500 && ptt_flag == 0) { // Pressed half a second, switch to push-to-talk // I configured my machine to toggle the input muting when F10 is clicked TrinketHidCombo.pressKey(0, KEYCODE_F10); TrinketHidCombo.pressKey(0, 0); ptt_flag = 1; } } } else { // Button not pressed if (time_pressed) {// Has been pressed time_pressed = 0; if (ptt_flag == 0) { // Was a short click // Toggle mute TrinketHidCombo.pressMultimediaKey(MMKEY_MUTE); } else { // Was a long click // Toggle push-to-talk TrinketHidCombo.pressKey(0, KEYCODE_F10); TrinketHidCombo.pressKey(0, 0); ptt_flag = 0; } } } TrinketHidCombo.poll(); }
Vivo en una casa muy vieja, tiene alrededor de 100 años, y eso tiene ventajas y desventajas. Ventajas: tiene mucha onda, luz natural, pisos de pinotea, aberturas antiguas de vidrio partido de colores.
Desventajas: las aberturas antiguas tienen vidrios de 6 décadas distintas, los pisos de pinotea son delicados, no hay un condenado enchufe y no hay adonde guardar nada porque en esa época la gente no tenía cosas.
Así que hará 35 años, en una remodelación, alguien abrió el espacio abajo de la escalera que va a la terraza y quedó un lugar de almacenaje al fondo del lavadero.
Y ahora, después de 15 años de vivir acá, decidí hacerlo lo más funcional posible.
Eso llevó un par de días porque ... había muchas cosas arrumbadas ahí adentro. Regalé una heladera, un minilavarropas, ollas viejas, y muchas otras cosas.
Es un espacio de 2,40m x 80cm. En la parte derecha mide 3m de alto. En la parte izquierda tiene la pendiente de la escalera.
Tiene una puerta de acceso de 1,60m de alto por 1m de ancho.
Quiero tener lugar para guardar todo, pero fundamentalmente:
Alimentos no perecederos
Fuentes y esas cosas
Herramientas
Productos de limpieza
Valijas
Cajas grandes varias con cosas
Quiero convertir la parte alta del espcio en una "repisa entrepiso" de almacenaje para valijas y cajas.
Agarré unas ménsulas viejas que encontré por ahí, unos perfiles en L de acero, tarugos y unos tablones e hice un marco para apoyar un panel de pino de 1,20 x 70.
Todo eso está a una altura de 1.85 así que puedo hasta pararme abajo sin problemas.
Ahí arriba irán entonces valijas, cajas, y bultos grandes que no quiero acceder seguido.
Es complicado porque los espacios a ambos lados son "profundos". Si pongo una estantería adelante los bloqueo, si pongo estanterías atrás son un poco inaccesibles porque hay poco espacio.
Y en la parte baja es aún peor porque como se hace para acceder a lo que se guarda en el fondo de todo?
Solución: estanterías móviles con rueditas.
Como no existen, me las tuve que arreglar.
Eso es una estantería jaula de acero de 6 estantes, mide 1,70m de altura, 70cm de profundidad y 1,20m de ancho. pesa alrededor de 90kg.
Y no pasa por la puerta de mi lavadero, ni por la entrada del bajoescalera que mide 1mx1,50m así que ...
La cortamos por la mitad a lo alto. La parte de arriba se va a convertir en la estantería para la parte "baja" izquierda y la parte de abajo en la estantería para la parte "alta" derecha.
La parte de abajo tiene ruedas. Pero obviamente la de arriba no.
Hice un "trineo" para la parte de abajo (de paso, gané un estante!)
La base se fija a la estantería usando unos perfiles en L, unas planchuelas, unos precintos y buena voluntad.
Para poder hacer esto, y que no quede espacio sin usar:
Quedé contento, se aprovechó muy bien el espacio (aunque todavía no usé el espacio para valijas). La estética es un poco rústica, pero ... es un bajoescalera atrás del lavadero, no me jodan.
Y fue un finde divertido jugando con herramientas.
Review:A nice sidequest, a story with a touch of the supernatural. Fun short read. |