Initial import

This commit is contained in:
erwin 2023-07-27 22:19:52 +02:00
parent a2c9424b31
commit 2d32ef8aef
13 changed files with 776 additions and 0 deletions

Binary file not shown.

BIN
cad/knob.FCStd Normal file

Binary file not shown.

View File

@ -0,0 +1,87 @@
#ifndef __MACRO_KEYBOARD_H__
#define __MACRO_KEYBOARD_H__
// Keypad defines
#define KEYBOARD_ROWS 3
#define KEYBOARD_COLS 4
#define KEYBOARD_KEY0 0
#define KEYBOARD_KEY1 1
#define KEYBOARD_KEY2 2
#define KEYBOARD_KEY3 3
#define KEYBOARD_KEY4 4
#define KEYBOARD_KEY5 5
#define KEYBOARD_KEY6 6
#define KEYBOARD_KEY7 7
#define KEYBOARD_KEY8 8
#define KEYBOARD_KEY9 9
#define KEYBOARD_KEYA 10
#define KEYBOARD_KEYB 11
#define KEYBOARD_KEYC 12
#define KEYBOARD_MODE0 0
#define KEYBOARD_MODE1 1
#define KEYBOARD_MODE2 2
#define KEYBOARD_MODE3 3
#define KEYBOARD_LAST_MODE 3
#define ROTARY_SENSITIVITY 4
char key = 0;
char keys[KEYBOARD_ROWS][KEYBOARD_COLS] = {
{KEYBOARD_KEY1, KEYBOARD_KEY2, KEYBOARD_KEY3, KEYBOARD_KEY4}, // the keyboard hardware is a 3x4 grid...
{KEYBOARD_KEY5, KEYBOARD_KEY6, KEYBOARD_KEY7, KEYBOARD_KEY8},
{KEYBOARD_KEY9, KEYBOARD_KEYA, KEYBOARD_KEYB, KEYBOARD_KEYC}, // these values need to be single char, so...
};
byte rowPins[KEYBOARD_ROWS] = {4, 5, A3 }; //connect to the row pinouts of the keypad
byte colPins[KEYBOARD_COLS] = {6, 7, 8, 9 }; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, KEYBOARD_ROWS, KEYBOARD_COLS );
// The library will return the character inside this array when the appropriate
// button is pressed then look for that case statement. This is the key assignment lookup table.
// Layout(key/button order) looks like this
// |----------------------------|
// | [2/3]* | *TRS breakout connection. Keys 2 and 3 are duplicated at the TRS jack
// | [ 1] [ 2] [ 3] [ 4] | * Encoder A location = key[1]
// | [ 5] [ 6] [ 7] [ 8] | * Encoder B location = Key[4]
// | [ 9] [ A] [ B] [ C] | NOTE: The mode button (0) is not row/column key, it's directly wired to A0!!
// |----------------------------|
#define KEYBOARD_MODEBUTTON_PIN A0 // the pin that the Modebutton is attached to
#define KEYBOARD_POT_PIN A1 // pot for adjusting attract mode demoTime or mouseMouse pixel value
// Rotary defines
Encoder RotaryEncoderA(16, 10); //the LEFT encoder (encoder A)
Encoder RotaryEncoderB(15, 14); //the RIGHT encoder (encoder B)
// Display defines
#define LCD_NB_ROWS 4 //for the 4x20 LCD lcd.begin(), but i think this is kinda redundant
#define LCD_NB_COLUMNS 20
unsigned long previousMillis = 0; // values to compare last time interval was checked (For LCD refreshing)
int check_State = 0; // state to check trigger the demo interrupt
int updateLCD_flag = 0; // LCD updater, this flag is used to only update the screen once between mode changes
// and once every 3 second while in a mode. Saves cycles / resources
LiquidCrystal_I2C lcd(0x3F, 20, 4); // set the LCD address for a 40 chars and 4 line display
// Neopixel defines
#define NEOPIXEL_PIN A2 // Which pin on the Arduino is connected to the NeoPixels?
#define NEOPIXEL_NUMPIXELS 13 // How many NeoPixels are attached to the Arduino? 13 total, but they are address from 0,1,2,...12.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NEOPIXEL_NUMPIXELS, NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800);
int colorUpdate = 0; //setting a flag to only update colors once when the mode is switched.
const int b = 3; // Brightness control variable. Used to divide the RBG vales set for the RGB LEDs. full range is 0-255. 255 is super bright
// In fact 255 is obnoxiously bright, so this use this variable to reduce the value. It also reduces the current draw on the USB
#define SYSTEM_KEY_WAIT 50
#define SYSTEM_GUI_WAIT 200
// Variables that will change:
int keyboardState = KEYBOARD_MODE0; // counter for the number of button presses
int buttonState = 0; // current state of the button
int lastButtonState = 0; // previous state of the button
int mouseMove;
long positionEncoderA = -999; //encoderA LEFT position variable
long positionEncoderB = -999; //encoderB RIGHT position variable
#endif

View File

@ -0,0 +1,119 @@
#ifdef __AVR__
#include <avr/power.h>
#endif
#include <HID-Project.h>
//#include <Keyboard.h>
//#include <Mouse.h>
#include <Keypad.h>
#include <Encoder.h>
#include <LiquidCrystal_I2C.h>
#include <Adafruit_NeoPixel.h>
#include "macro_keyboard.h"
void setup() {
pinMode(KEYBOARD_MODEBUTTON_PIN, INPUT_PULLUP); // initialize the mode-button pin as a input
Consumer.begin(); // initialize the MediaPlayer functions
Keyboard.begin(); // initialize the keypad
pixels.begin(); // initialize the NeoPixels
lcd.init(); // initialize the 4x20 lcd
lcd.backlight(); //turn on the backlight
lcd.begin(LCD_NB_COLUMNS , LCD_NB_ROWS);
lcd.setCursor(0, 0); lcd.print("Macro KB RC V2.0");
lcd.setCursor(0, 1); lcd.print("(c) 2020 Ryan Bates");
positionEncoderA = RotaryEncoderA.read()/ROTARY_SENSITIVITY;
positionEncoderB = RotaryEncoderA.read()/ROTARY_SENSITIVITY;
for (int i = 0; i <= (KEYBOARD_ROWS * KEYBOARD_COLS); i++) {
pixels.setPixelColor(i, pixels.Color( 15, 15, 15));
pixels.show();
delay(20);
}
/*
for (int i = 0; i <= (KEYBOARD_ROWS * KEYBOARD_COLS); i++) {
pixels.setPixelColor(i, pixels.Color(127, 0, 0));
pixels.show();
delay(25);
}
delay(100);
for (int i = (KEYBOARD_ROWS * KEYBOARD_COLS); i >= 0; i--) {
pixels.setPixelColor(i, pixels.Color( 0, 127, 0));
pixels.show();
delay(25);
}
delay(100);
for (int i = 0; i <= (KEYBOARD_ROWS * KEYBOARD_COLS); i++) {
pixels.setPixelColor(i, pixels.Color( 0, 0, 127));
pixels.show();
delay(25);
}
delay(100);
for (int i = (KEYBOARD_ROWS * KEYBOARD_COLS); i >= 0; i--) {
pixels.setPixelColor(i, pixels.Color( 0, 0, 0));
pixels.show();
delay(25);
}
delay(100);
*/
colorUpdate = 1;
}
void loop() {
key = keypad.getKey();
// mouseMove = (analogRead(KEYBOARD_POT_PIN)); //reading the analog input, pot = pin A1
// mouseMove = map(mouseMove, 0,1023, 1,124); //remap the analog pot values fron 1 to 124
switch (keyboardMode()) { // switch between keyboard configurations:
case KEYBOARD_MODE0:
keyboard_Mode0();
encoderA_Mode0();
encoderB_Mode0();
colors_Mode0();
display_Mode0();
break;
case KEYBOARD_MODE1:
keyboard_Mode1();
encoderA_Mode1();
encoderB_Mode1();
colors_Mode1();
display_Mode1();
break;
case KEYBOARD_MODE2:
keyboard_Mode2();
encoderA_Mode2();
encoderB_Mode2();
colors_Mode2();
display_Mode2();
break;
case KEYBOARD_MODE3:
keyboard_Mode3();
encoderA_Mode3();
encoderB_Mode3();
colors_Mode3();
display_Mode3();
break;
}
delay(1); // delay in between reads for stability
}
char keyboardMode() {
buttonState = digitalRead(KEYBOARD_MODEBUTTON_PIN);
if (buttonState != lastButtonState) { // compare the buttonState to its previous state
if (buttonState == LOW) { // if the state has changed, increment the counter
// if the current state is LOW then the button cycled:
keyboardState++;
colorUpdate = 1; // set the color change flag ONLY when we know the mode button has been pressed.
// Saves processor resources from updating the neoPixel colors all the time
}
delay(10); // Delay a little bit to avoid bouncing
}
lastButtonState = buttonState; // save the current state as the last state, for next time through the loop
if (keyboardState > KEYBOARD_LAST_MODE) { //reset the counter after 4 presses CHANGE THIS FOR MORE MODES
keyboardState = KEYBOARD_MODE0;
}
return keyboardState;
}

View File

@ -0,0 +1,158 @@
// Linux commands
void keyboard_Mode0() {
if (key) {
switch (key) {
case KEYBOARD_KEY1:
Consumer.write(MEDIA_VOLUME_MUTE);
break;
case KEYBOARD_KEY2:
Keyboard.press(KEY_LEFT_GUI); delay(SYSTEM_KEY_WAIT); Keyboard.release(KEY_LEFT_GUI); delay(SYSTEM_GUI_WAIT);
Keyboard.print("firefox"); delay(SYSTEM_GUI_WAIT);
Keyboard.press(KEY_RETURN); delay(SYSTEM_KEY_WAIT); Keyboard.release(KEY_RETURN);
pixels.setPixelColor(KEYBOARD_KEY2, pixels.Color( 0, 127, 0));
break;
case KEYBOARD_KEY3:
Keyboard.press(KEY_LEFT_GUI); delay(SYSTEM_KEY_WAIT); Keyboard.release(KEY_LEFT_GUI); delay(SYSTEM_GUI_WAIT);
Keyboard.print("spotify"); delay(SYSTEM_GUI_WAIT);
Keyboard.press(KEY_RETURN);
pixels.setPixelColor(KEYBOARD_KEY3, pixels.Color( 0, 127, 0));
break;
case KEYBOARD_KEY4:
Consumer.write(MEDIA_PLAY_PAUSE);
break;
case KEYBOARD_KEY5:
Keyboard.press(KEY_LEFT_GUI); delay(SYSTEM_KEY_WAIT); Keyboard.release(KEY_LEFT_GUI); delay(SYSTEM_GUI_WAIT);
Keyboard.println("keepassxc"); delay(SYSTEM_GUI_WAIT);
Keyboard.press(KEY_ENTER);
pixels.setPixelColor(KEYBOARD_KEY5, pixels.Color( 0, 127, 0));
break;
case KEYBOARD_KEY6:
Keyboard.press(KEY_LEFT_GUI); delay(SYSTEM_KEY_WAIT); Keyboard.release(KEY_LEFT_GUI); delay(SYSTEM_GUI_WAIT);
Keyboard.print("kicad"); delay(SYSTEM_GUI_WAIT);
Keyboard.press(KEY_RETURN);
pixels.setPixelColor(KEYBOARD_KEY6, pixels.Color( 0, 127, 0));
break;
case KEYBOARD_KEY7:
Keyboard.press(KEY_LEFT_GUI); delay(SYSTEM_KEY_WAIT); Keyboard.release(KEY_LEFT_GUI); delay(SYSTEM_GUI_WAIT);
Keyboard.print("inkscape"); delay(SYSTEM_GUI_WAIT);
Keyboard.press(KEY_RETURN);
pixels.setPixelColor(KEYBOARD_KEY7, pixels.Color( 0, 127, 0));
break;
case KEYBOARD_KEY8:
Keyboard.press(KEY_LEFT_GUI); delay(SYSTEM_KEY_WAIT); Keyboard.release(KEY_LEFT_GUI); delay(SYSTEM_GUI_WAIT);
Keyboard.print("freecad"); delay(SYSTEM_GUI_WAIT);
Keyboard.press(KEY_RETURN);
pixels.setPixelColor(KEYBOARD_KEY8, pixels.Color( 0, 127, 0));
break;
case KEYBOARD_KEY9:
Keyboard.press(KEY_LEFT_GUI); delay(SYSTEM_KEY_WAIT); Keyboard.release(KEY_LEFT_GUI); delay(SYSTEM_GUI_WAIT);
Keyboard.print("screenshot"); delay(SYSTEM_GUI_WAIT);
Keyboard.press(KEY_RETURN);
pixels.setPixelColor(KEYBOARD_KEY9, pixels.Color( 0, 127, 0));
break;
case KEYBOARD_KEYA:
Keyboard.press(KEY_LEFT_GUI); delay(SYSTEM_KEY_WAIT); Keyboard.release(KEY_LEFT_GUI); delay(SYSTEM_GUI_WAIT);
Keyboard.print("calculator"); delay(SYSTEM_GUI_WAIT);
Keyboard.press(KEY_RETURN);
pixels.setPixelColor(KEYBOARD_KEYA, pixels.Color( 0, 127, 0));
break;
case KEYBOARD_KEYB:
Keyboard.press(KEY_LEFT_GUI); delay(SYSTEM_KEY_WAIT); Keyboard.release(KEY_LEFT_GUI); delay(SYSTEM_GUI_WAIT);
Keyboard.print("lightburn"); delay(SYSTEM_GUI_WAIT);
Keyboard.press(KEY_RETURN);
pixels.setPixelColor(KEYBOARD_KEYB, pixels.Color( 0, 127, 0));
break;
case KEYBOARD_KEYC:
Keyboard.press(KEY_LEFT_GUI); delay(SYSTEM_KEY_WAIT); Keyboard.release(KEY_LEFT_GUI); delay(SYSTEM_GUI_WAIT);
Keyboard.print("prusa"); delay(SYSTEM_GUI_WAIT);
Keyboard.press(KEY_RETURN);
pixels.setPixelColor(KEYBOARD_KEYC, pixels.Color( 0, 127, 0));
break;
}
pixels.show();
delay(SYSTEM_KEY_WAIT);
Keyboard.releaseAll();
colorUpdate = 1;
}
}
void colors_Mode0() {
if (colorUpdate == 1) {
pixels.setPixelColor(KEYBOARD_KEY0, pixels.Color( 0, 0, 0)); // off
pixels.setPixelColor(KEYBOARD_KEY1, pixels.Color( 0, 0, 0)); // off
pixels.setPixelColor(KEYBOARD_KEY2, pixels.Color( 127, 31, 0)); // orange
pixels.setPixelColor(KEYBOARD_KEY3, pixels.Color( 0, 63, 0)); // green
pixels.setPixelColor(KEYBOARD_KEY4, pixels.Color( 0, 0, 0)); // off
pixels.setPixelColor(KEYBOARD_KEY5, pixels.Color( 0, 127, 0)); // green
pixels.setPixelColor(KEYBOARD_KEY6, pixels.Color( 127, 63, 0)); // yellow
pixels.setPixelColor(KEYBOARD_KEY7, pixels.Color( 63, 63, 127)); // cyan
pixels.setPixelColor(KEYBOARD_KEY8, pixels.Color( 31, 31, 63)); // gray
pixels.setPixelColor(KEYBOARD_KEY9, pixels.Color( 15, 15, 127)); // blue
pixels.setPixelColor(KEYBOARD_KEYA, pixels.Color( 127, 31, 0)); // orange
pixels.setPixelColor(KEYBOARD_KEYB, pixels.Color( 127, 0, 0)); // red
pixels.setPixelColor(KEYBOARD_KEYC, pixels.Color( 127, 31, 0)); // orange
pixels.show();
colorUpdate = 0;
}
}
void encoderA_Mode0(){
long newPos = RotaryEncoderA.read()/ROTARY_SENSITIVITY;
if (newPos != positionEncoderA && newPos < positionEncoderA) {
positionEncoderA = newPos;
Consumer.write(MEDIA_VOLUME_UP);
}
if (newPos != positionEncoderA && newPos > positionEncoderA) {
positionEncoderA = newPos;
Consumer.write(MEDIA_VOLUME_DOWN);
}
}
void encoderB_Mode1(){
long newPos = RotaryEncoderB.read()/ROTARY_SENSITIVITY;
if (newPos != positionEncoderB && newPos < positionEncoderB) {
positionEncoderB = newPos;
Consumer.write(MEDIA_NEXT);
}
if (newPos != positionEncoderB && newPos > positionEncoderB) {
positionEncoderB = newPos;
Consumer.write(MEDIA_PREVIOUS);
}
}
void display_Mode0() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= 3000) { // if the elasped time greater than 3 seconds
previousMillis = currentMillis; // save the last time you checked the interval
switch (updateLCD_flag) {
case 0:
lcd.clear();
lcd.setCursor(0, 0); lcd.print("1: empty");
lcd.setCursor(0, 1); lcd.print("2: Terminal");
lcd.setCursor(0, 2); lcd.print("3: Firefox");
lcd.setCursor(0, 3); lcd.print("4: alt+F4");
updateLCD_flag = 1;
break;
case 1:
lcd.clear();
lcd.setCursor(0, 0); lcd.print("5: empty");
lcd.setCursor(0, 1); lcd.print("6: KiCAD");
lcd.setCursor(0, 2); lcd.print("7: Inkscape");
lcd.setCursor(0, 3); lcd.print("8: FreeCAD");
updateLCD_flag = 2;
break;
case 2:
lcd.clear();
lcd.setCursor(0, 0); lcd.print(" 9: empty");
lcd.setCursor(0, 1); lcd.print("SYSTEM_KEY_WAIT: empty");
lcd.setCursor(0, 2); lcd.print("11: LightBurn");
lcd.setCursor(0, 3); lcd.print("12: PrusaSlicer");
updateLCD_flag = 0;
break;
}
}
}

View File

@ -0,0 +1,124 @@
// Teams
void keyboard_Mode1() {
if (key) {
switch (key) {
case KEYBOARD_KEY1: // mute
Consumer.write(MEDIA_VOLUME_MUTE);
break;
case KEYBOARD_KEY2: // chat
pixels.setPixelColor(KEYBOARD_KEY2, pixels.Color(0,150,0));
break;
case KEYBOARD_KEY3: // spotify
Keyboard.press(KEY_LEFT_GUI); delay(SYSTEM_KEY_WAIT); Keyboard.release(KEY_LEFT_GUI); delay(SYSTEM_GUI_WAIT);
Keyboard.print("spotify"); delay(SYSTEM_GUI_WAIT);
Keyboard.press(KEY_RETURN);
pixels.setPixelColor(KEYBOARD_KEY3, pixels.Color(0,150,0));
break;
case KEYBOARD_KEY4:
Consumer.write(MEDIA_PLAY_PAUSE);
break;
case KEYBOARD_KEY5: // accept audio
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press(KEY_LEFT_SHIFT);
Keyboard.print('a');
pixels.setPixelColor(KEYBOARD_KEY5, pixels.Color(0,150,0));
break;
case KEYBOARD_KEY6: // raise hand
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press(KEY_LEFT_SHIFT);
Keyboard.print('k');
pixels.setPixelColor(KEYBOARD_KEY6, pixels.Color(0,150,0));
break;
case KEYBOARD_KEY7: // share screen
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press(KEY_LEFT_SHIFT);
Keyboard.print('e');
pixels.setPixelColor(KEYBOARD_KEY7, pixels.Color(0,150,0));
break;
case KEYBOARD_KEY8: // escape
Keyboard.press(KEY_ESC);
pixels.setPixelColor(KEYBOARD_KEY8, pixels.Color(0,150,0));
break;
case KEYBOARD_KEY9: // accept video call
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press(KEY_LEFT_SHIFT);
Keyboard.print('a');
pixels.setPixelColor(KEYBOARD_KEY9, pixels.Color(0,150,0));
break;
case KEYBOARD_KEYA: // toggle microphone
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press(KEY_LEFT_SHIFT);
Keyboard.print('m');
pixels.setPixelColor(KEYBOARD_KEYA, pixels.Color(0,150,0));
break;
case KEYBOARD_KEYB: // toggle camera
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press(KEY_LEFT_SHIFT);
Keyboard.print('o');
pixels.setPixelColor(KEYBOARD_KEYB, pixels.Color(0,150,0));
break;
case KEYBOARD_KEYC: // hang up
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press(KEY_LEFT_SHIFT);
Keyboard.print('h');
pixels.setPixelColor(KEYBOARD_KEYC, pixels.Color(0,150,0));
break;
}
pixels.show();
delay(SYSTEM_KEY_WAIT);
Keyboard.releaseAll();
colorUpdate = 1;
}
}
void colors_Mode1() {
if (colorUpdate == 1) {
pixels.setPixelColor(KEYBOARD_KEY0, pixels.Color( 0, 0, 0)); // off
pixels.setPixelColor(KEYBOARD_KEY1, pixels.Color( 0, 0, 0)); // off
pixels.setPixelColor(KEYBOARD_KEY2, pixels.Color( 0, 0, 0)); // off
pixels.setPixelColor(KEYBOARD_KEY3, pixels.Color( 0, 63, 0)); // green
pixels.setPixelColor(KEYBOARD_KEY4, pixels.Color( 0, 0, 0)); // off
pixels.setPixelColor(KEYBOARD_KEY5, pixels.Color( 0, 31, 0)); // accept audio
pixels.setPixelColor(KEYBOARD_KEY6, pixels.Color( 31, 31, 0)); // raise hand
pixels.setPixelColor(KEYBOARD_KEY7, pixels.Color( 31, 31, 31)); // screen share
pixels.setPixelColor(KEYBOARD_KEY8, pixels.Color( 0, 0, 0)); // off
pixels.setPixelColor(KEYBOARD_KEY9, pixels.Color( 0, 127, 0)); // accept video
pixels.setPixelColor(KEYBOARD_KEYA, pixels.Color( 0, 0, 127)); // toggle microphone
pixels.setPixelColor(KEYBOARD_KEYB, pixels.Color( 0, 0, 31)); // toggle camera
pixels.setPixelColor(KEYBOARD_KEYC, pixels.Color(127, 0, 0)); // hang up
pixels.show();
colorUpdate = 0;
}
}
void encoderA_Mode1(){
long newPos = RotaryEncoderA.read()/ROTARY_SENSITIVITY;
if (newPos != positionEncoderA && newPos < positionEncoderA) {
positionEncoderA = newPos;
Consumer.write(MEDIA_VOLUME_UP);
}
if (newPos != positionEncoderA && newPos > positionEncoderA) {
positionEncoderA = newPos;
Consumer.write(MEDIA_VOLUME_DOWN);
}
}
void encoderB_Mode0(){
long newPos = RotaryEncoderB.read()/ROTARY_SENSITIVITY;
if (newPos != positionEncoderB && newPos < positionEncoderB) {
positionEncoderB = newPos;
Consumer.write(MEDIA_NEXT);
}
if (newPos != positionEncoderB && newPos > positionEncoderB) {
positionEncoderB = newPos;
Consumer.write(MEDIA_PREVIOUS);
}
}
void display_Mode1() {
}

View File

@ -0,0 +1,116 @@
// FreeCAD
void keyboard_Mode2() {
if (key) {
switch (key) {
case KEYBOARD_KEY1: // mute
Consumer.write(MEDIA_VOLUME_MUTE);
break;
case KEYBOARD_KEY2: // line
Keyboard.print('l');
pixels.setPixelColor(KEYBOARD_KEY2, pixels.Color(0,150,0));
break;
case KEYBOARD_KEY3: // escape
Keyboard.press(KEY_ESC);
pixels.setPixelColor(KEYBOARD_KEY3, pixels.Color(0,150,0));
break;
case KEYBOARD_KEY4: // zoom to 100%
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.print('0');
break;
case KEYBOARD_KEY5: // vertical constraint
pixels.setPixelColor(KEYBOARD_KEY5, pixels.Color(0,150,0));
Keyboard.print('v');
break;
case KEYBOARD_KEY6: // horizontal constraint
Keyboard.print('h');
pixels.setPixelColor(KEYBOARD_KEY6, pixels.Color(0,150,0));
break;
case KEYBOARD_KEY7: // point constraint
Keyboard.print('c');
pixels.setPixelColor(KEYBOARD_KEY7, pixels.Color(0,150,0));
break;
case KEYBOARD_KEY8: // tangent constraint
Keyboard.print('t');
pixels.setPixelColor(KEYBOARD_KEY8, pixels.Color(0,150,0));
break;
case KEYBOARD_KEY9: // vertical length constraint
Keyboard.press(KEY_LEFT_SHIFT);
Keyboard.print('v');
pixels.setPixelColor(KEYBOARD_KEY9, pixels.Color(0,150,0));
break;
case KEYBOARD_KEYA: // horizontal length constraint
Keyboard.press(KEY_LEFT_SHIFT);
Keyboard.print('h');
pixels.setPixelColor(KEYBOARD_KEYA, pixels.Color(0,150,0));
break;
case KEYBOARD_KEYB: // ortogonal constraint
Keyboard.press(KEY_LEFT_SHIFT);
Keyboard.print('o');
pixels.setPixelColor(KEYBOARD_KEYB, pixels.Color(0,150,0));
break;
case KEYBOARD_KEYC: // symmetry constraint
Keyboard.print('o');
pixels.setPixelColor(KEYBOARD_KEYC, pixels.Color(0,150,0));
break;
}
pixels.show();
delay(100);
Keyboard.releaseAll();
colorUpdate = 1;
}
}
void colors_Mode2() {
if (colorUpdate == 1) {
pixels.setPixelColor(KEYBOARD_KEY0, pixels.Color( 0, 0, 0)); // off
pixels.setPixelColor(KEYBOARD_KEY1, pixels.Color( 0, 0, 0)); // off
pixels.setPixelColor(KEYBOARD_KEY2, pixels.Color( 15, 15, 15)); // white
pixels.setPixelColor(KEYBOARD_KEY3, pixels.Color( 0, 0, 0)); // off
pixels.setPixelColor(KEYBOARD_KEY4, pixels.Color( 0, 0, 0)); // off
pixels.setPixelColor(KEYBOARD_KEY5, pixels.Color( 15, 0, 0)); // red
pixels.setPixelColor(KEYBOARD_KEY6, pixels.Color( 15, 0, 0)); // red
pixels.setPixelColor(KEYBOARD_KEY7, pixels.Color( 15, 0, 0)); // red
pixels.setPixelColor(KEYBOARD_KEY8, pixels.Color( 15, 0, 0)); // red
pixels.setPixelColor(KEYBOARD_KEY9, pixels.Color( 63, 0, 0)); // red
pixels.setPixelColor(KEYBOARD_KEYA, pixels.Color( 63, 0, 0)); // red
pixels.setPixelColor(KEYBOARD_KEYB, pixels.Color( 15, 0, 0)); // red
pixels.setPixelColor(KEYBOARD_KEYC, pixels.Color( 15, 0, 0)); // red
pixels.show();
colorUpdate = 0;
}
}
void encoderA_Mode2(){
long newPos = RotaryEncoderA.read()/ROTARY_SENSITIVITY;
if (newPos != positionEncoderA && newPos < positionEncoderA) {
positionEncoderA = newPos;
Consumer.write(MEDIA_VOLUME_UP);
}
if (newPos != positionEncoderA && newPos > positionEncoderA) {
positionEncoderA = newPos;
Consumer.write(MEDIA_VOLUME_DOWN);
}
}
void encoderB_Mode2(){
long newPos = RotaryEncoderB.read()/ROTARY_SENSITIVITY;
if (newPos != positionEncoderB && newPos < positionEncoderB) {
positionEncoderB = newPos;
Keyboard.press(KEY_RIGHT_CTRL);
Mouse.move(0, 0, 1);
Keyboard.release(KEY_RIGHT_CTRL);
}
if (newPos != positionEncoderB && newPos > positionEncoderB) {
positionEncoderB = newPos;
Keyboard.press(KEY_RIGHT_CTRL);
Mouse.move(0, 0, -1);
Keyboard.release(KEY_RIGHT_CTRL);
}
}
void display_Mode2() {
}

View File

@ -0,0 +1,172 @@
// Empty
void keyboard_Mode3() {
if (key) {
switch (key) {
case KEYBOARD_KEY1: //macro example!!! Windows1_Key+R = Run then type "mspaint" and press enter. Opens MS Paint
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press('r'); delay(0);
Keyboard.release(KEY_LEFT_GUI);
Keyboard.release('r');
delay(0); //give your system time to catch up with these android-speed keyboard presses
Keyboard.println("mspaint");
break;
case KEYBOARD_KEY2:
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press(KEY_LEFT_ARROW); delay(0); //snaps window to left side of screen.
break;
case KEYBOARD_KEY3:
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press(KEY_RIGHT_ARROW); delay(0); //snaps window to right side of screen.
break;
case KEYBOARD_KEY4:
for (int i = 0; i <= (KEYBOARD_ROWS * KEYBOARD_COLS); i++) {
pixels.setPixelColor(i, pixels.Color(127, 0, 0));
pixels.show();
delay(25);
}
delay(100);
for (int i = (KEYBOARD_ROWS * KEYBOARD_COLS); i >= 0; i--) {
pixels.setPixelColor(i, pixels.Color( 0, 127, 0));
pixels.show();
delay(25);
}
delay(100);
for (int i = 0; i <= (KEYBOARD_ROWS * KEYBOARD_COLS); i++) {
pixels.setPixelColor(i, pixels.Color( 0, 0, 127));
pixels.show();
delay(25);
}
delay(100);
for (int i = (KEYBOARD_ROWS * KEYBOARD_COLS); i >= 0; i--) {
pixels.setPixelColor(i, pixels.Color( 0, 0, 0));
pixels.show();
delay(25);
}
delay(100);
colorUpdate = 1;
break;
case KEYBOARD_KEY5: //macro example: Windows_Key+R = Run then type "calc" and press enter. Opens MS Calculator
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press('r'); delay(0);
Keyboard.release(KEY_LEFT_GUI);
Keyboard.release('r');
delay(0); //give your system time to catch up with these android-speed keyboard presses
Keyboard.println("calc");
break;
case KEYBOARD_KEY6: //macro example: Windows_Key+R = Run then type "excel" and press enter. Opens MS Excel
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press('r'); delay(0);
Keyboard.release(KEY_LEFT_GUI);
Keyboard.release('r');
delay(0); //give your system time to catch up with these android-speed keyboard presses
Keyboard.println("excel");
break; Keyboard.press(KEY_LEFT_CTRL);
case KEYBOARD_KEY7: //macro example: Windows_Key+R = Run then type "winword" and press enter. Opens MS Word
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press('r'); delay(0);
Keyboard.release(KEY_LEFT_GUI);
Keyboard.release('r');
delay(0); //give your system time to catch up with these android-speed keyboard presses
Keyboard.println("winword");
break;
case KEYBOARD_KEY8: //macro that opens chrome and a random wiki page for learning.
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press('r');
Keyboard.release(KEY_LEFT_GUI);
Keyboard.release('r');
delay(50); //give your system time to catch up with these android-speed keyboard presses
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press(KEY_LEFT_SHIFT);
Keyboard.print('a');
Keyboard.println("chrome"); delay(500);
Keyboard.println("https://en.wikipedia.org/wiki/Special:Random");
break;
case KEYBOARD_KEY9: //macro that opens Chrome & Rick Rolls you like a chump
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press('r');
Keyboard.release(KEY_LEFT_GUI);
Keyboard.release('r');
delay(50); //give your system time to catch up with these android-speed keyboard presses
Keyboard.println("chrome"); delay(500);
Keyboard.println("https://www.yout1ube.com/watch?v=dQw4w9WgXcQ");
break;
case KEYBOARD_KEYA: //macro that opens Chrome and goes to my youtube channel!
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press('r');
Keyboard.release(KEY_LEFT_GUI);
Keyboard.release('r');
delay(50); //give your system time to catch up with these android-speed keyboard presses
Keyboard.println("chrome"); delay(500);
Keyboard.println("https://www.youtube.com/c/ryanbatesrbg");
break;
case KEYBOARD_KEYB: //minimize all windows (view desktop)
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press('m');
break;
case KEYBOARD_KEYC:
Keyboard.press(KEY_LEFT_GUI); //Opens Snip-it
Keyboard.release(KEY_LEFT_GUI); delay(25);
Keyboard.println("snip"); //type "snip" and press "return"
break;
}
delay(100);
Keyboard.releaseAll(); // this releases the buttons
}
} // neoPixels have been updated.
// Set the flag to 1; so they are not updated until a Mode change
void colors_Mode3() {
if (colorUpdate == 1) {
pixels.setPixelColor(KEYBOARD_KEY0, pixels.Color( 7, 0, 0)); // red
pixels.setPixelColor(KEYBOARD_KEY1, pixels.Color( 0, 0, 0)); // off
pixels.setPixelColor(KEYBOARD_KEY2, pixels.Color( 0, 0, 0)); // off
pixels.setPixelColor(KEYBOARD_KEY3, pixels.Color( 0, 0, 0)); // off
pixels.setPixelColor(KEYBOARD_KEY4, pixels.Color( 0, 0, 0)); // off
pixels.setPixelColor(KEYBOARD_KEY5, pixels.Color( 0, 0, 0)); // off
pixels.setPixelColor(KEYBOARD_KEY6, pixels.Color( 0, 0, 0)); // off
pixels.setPixelColor(KEYBOARD_KEY7, pixels.Color( 0, 0, 0)); // off
pixels.setPixelColor(KEYBOARD_KEY8, pixels.Color( 0, 0, 0)); // off
pixels.setPixelColor(KEYBOARD_KEY9, pixels.Color( 0, 0, 0)); // off
pixels.setPixelColor(KEYBOARD_KEYA, pixels.Color( 0, 0, 0)); // off
pixels.setPixelColor(KEYBOARD_KEYB, pixels.Color( 0, 0, 0)); // off
pixels.setPixelColor(KEYBOARD_KEYC, pixels.Color( 0, 0, 0)); // off
pixels.show();
colorUpdate = 0;
}
}
void encoderA_Mode3(){
long newPos = RotaryEncoderA.read()/ROTARY_SENSITIVITY;
if (newPos != positionEncoderA && newPos < positionEncoderA) {
positionEncoderA = newPos;
Consumer.write(MEDIA_VOLUME_UP);
}
if (newPos != positionEncoderA && newPos > positionEncoderA) {
positionEncoderA = newPos;
Consumer.write(MEDIA_VOLUME_DOWN);
}
}
void encoderB_Mode3(){
long newPos = RotaryEncoderB.read()/ROTARY_SENSITIVITY;
if (newPos != positionEncoderB && newPos < positionEncoderB) {
positionEncoderB = newPos;
Keyboard.press(KEY_RIGHT_CTRL);
Mouse.move(0, 0, 1);
Keyboard.release(KEY_RIGHT_CTRL);
}
if (newPos != positionEncoderB && newPos > positionEncoderB) {
positionEncoderB = newPos;
Keyboard.press(KEY_RIGHT_CTRL);
Mouse.move(0, 0, -1);
Keyboard.release(KEY_RIGHT_CTRL);
}
}
void display_Mode3() {
}

BIN
production/3dprint_knob.stl Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.