Add libraries, picocalc notes.

This commit is contained in:
2025-04-01 18:28:52 -07:00
parent 1c3052c977
commit e77a69ce91
598 changed files with 475037 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
#include <PCKeyboard.h>
#define CARD_DET 1
PCKeyboard keyboard;
int prevValue = LOW;
void setup()
{
Serial.begin(9600);
Wire.setSDA(4);
Wire.setSCL(5);
Wire.begin();
Wire.setClock(10000);
keyboard.begin();
keyboard.pinMode(CARD_DET, INPUT);
keyboard.digitalWrite(CARD_DET, HIGH); // Enable pull-up
}
void loop()
{
const int value = keyboard.digitalRead(CARD_DET);
if (value == prevValue)
return;
Serial.printf("Card Detect: %d \r\n", value);
prevValue = value;
}

View File

@@ -0,0 +1,51 @@
#include <PCKeyboard.h>
PCKeyboard keyboard;
volatile bool dataReady = false;
const int interruptPin = 5;
void KeyIsr(void)
{
dataReady = true;
}
void setup()
{
Serial.begin(9600);
Wire.setSDA(4);
Wire.setSCL(5);
Wire.begin();
Wire.setClock(10000);
keyboard.begin();
keyboard.attachInterrupt(interruptPin, KeyIsr);
keyboard.setBacklight(0.5f);
}
void loop()
{
if (!dataReady)
return;
const PCKeyboard::KeyEvent key = keyboard.keyEvent();
String state = "pressed";
if (key.state == PCKeyboard::StateLongPress)
state = "held down";
else if (key.state == PCKeyboard::StateRelease)
state = "released";
Serial.printf("key: '%c' (dec %d, hex %02x) %s\r\n", key.key, key.key, key.key, state.c_str());
// pressing 'b' turns off the backlight and pressing Shift+b turns it on
if (key.state == PCKeyboard::StatePress) {
if (key.key == 'b') {
keyboard.setBacklight(0);
} else if (key.key == 'B') {
keyboard.setBacklight(1.0);
}
}
keyboard.clearInterruptStatus();
dataReady = false;
}

View File

@@ -0,0 +1,41 @@
#include <PCKeyboard.h>
PCKeyboard keyboard;
void setup()
{
Serial.begin(9600);
Wire.setSDA(4);
Wire.setSCL(5);
Wire.begin();
Wire.setClock(10000);
keyboard.begin();
keyboard.setBacklight(0.5f);
}
void loop()
{
const int keyCount = keyboard.keyCount();
if (keyCount == 0)
return;
const PCKeyboard::KeyEvent key = keyboard.keyEvent();
String state = "pressed";
if (key.state == PCKeyboard::StateLongPress)
state = "held down";
else if (key.state == PCKeyboard::StateRelease)
state = "released";
Serial.printf("key: '%c' (dec %d, hex %02x) %s\r\n", key.key, key.key, key.key, state.c_str());
// pressing 'b' turns off the backlight and pressing Shift+b turns it on
if (key.state == PCKeyboard::StatePress) {
if (key.key == 'b') {
keyboard.setBacklight(0);
} else if (key.key == 'B') {
keyboard.setBacklight(1.0);
}
}
}