gokul/macro-six-usbc
A six-key macro keyboard PCB paired with a separate physical enclosure.
- Version
- 0.1.16
- License
- unset
- Stars
- 0
Use with the tscircuit CLI
tsci is the tscircuit CLI. Install it with npm install -g tscircuit.
tsci clone gokul/macro-six-usbc # download the package files into ./macro-six-usbc
tsci add gokul/macro-six-usbc # add it to your project as @tsci/gokul.macro-six-usbcIn a cloned or new (tsci init) project: tsci dev starts a local preview, tsci build outputs Circuit JSON, and tsci push publishes to tscircuit.com.
firmware/inputs.c
#include "inputs.h"
#include <string.h>
void inputs_init(Inputs *inputs, uint8_t ab) {
memset(inputs,0,sizeof(*inputs));inputs->previous_ab=ab&3;
}
void inputs_tick(Inputs *s,uint8_t pressed,uint8_t ab) {
for(uint8_t i=0;i<7;i++) {
uint8_t mask=1u<<i;
if((pressed^s->candidate)&mask) {s->candidate^=mask;s->count[i]=0;}
if(s->count[i]<DEBOUNCE_MS) s->count[i]++;
if(s->count[i]==DEBOUNCE_MS && ((s->stable^s->candidate)&mask)) {
s->stable^=mask;
if(i==6 && (s->stable&mask) && s->mute_presses<16)s->mute_presses++;
}
}
static const int8_t transitions[16]={0,-1,1,0,1,0,0,-1,-1,0,0,1,0,1,-1,0};
ab&=3;
if((ab^s->previous_ab)==3)s->quarter_steps=0;
else s->quarter_steps+=transitions[(s->previous_ab<<2)|ab];
s->previous_ab=ab;
if(s->quarter_steps>=ENCODER_TRANSITIONS_PER_DETENT) {if(s->volume_steps<32)s->volume_steps++;s->quarter_steps=0;}
if(s->quarter_steps<=-ENCODER_TRANSITIONS_PER_DETENT) {if(s->volume_steps>-32)s->volume_steps--;s->quarter_steps=0;}
}