custom characters contd

main
radex 2024-02-22 15:09:10 +01:00
parent a88212a40d
commit 43c12c65a5
Signed by: radex
SSH Key Fingerprint: SHA256:hvqRXAGG1h89yqnS+cyFTLKQbzjWD4uXIqw7Y+0ws30
4 changed files with 198 additions and 78 deletions

155
firmware/src/characters.cpp Normal file
View File

@ -0,0 +1,155 @@
#include "characters.h"
uint8_t invertedA[8] = {
0b11111,
0b10001,
0b10101,
0b10001,
0b10101,
0b10101,
0b11111,
0b00000,
};
uint8_t invertedB[8] = {
0b11111,
0b10011,
0b10101,
0b10011,
0b10101,
0b10011,
0b11111,
0b00000,
};
uint8_t invertedC[8] = {
0b11111,
0b11001,
0b10111,
0b10111,
0b10111,
0b11001,
0b11111,
0b00000,
};
uint8_t invertedD[8] = {
0b11111,
0b10011,
0b10101,
0b10101,
0b10101,
0b10011,
0b11111,
0b00000,
};
uint8_t encoder[8] = {
0b01110,
0b10001,
0b00011,
0b11000,
0b10001,
0b01110,
0b00000,
0b00000,
};
uint8_t encoderSwitch[8] = {
0b00000,
0b01110,
0b10001,
0b10101,
0b10001,
0b01110,
0b00000,
0b00000,
};
uint8_t progressLeftMask[8] = {
0b10000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b10000,
0b00000,
};
uint8_t progressRightMask[8] = {
0b00001,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00001,
0b00000,
};
uint8_t progress0[8] = {
0b11111,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b11111,
0b00000,
};
uint8_t progress1[8] = {
0b11111,
0b10000,
0b10000,
0b10000,
0b10000,
0b10000,
0b11111,
0b00000,
};
uint8_t progress2[8] = {
0b11111,
0b11000,
0b11000,
0b11000,
0b11000,
0b11000,
0b11111,
0b00000,
};
uint8_t progress3[8] = {
0b11111,
0b11100,
0b11100,
0b11100,
0b11100,
0b11100,
0b11111,
0b00000,
};
uint8_t progress4[8] = {
0b11111,
0b11110,
0b11110,
0b11110,
0b11110,
0b11110,
0b11111,
0b00000,
};
uint8_t progress5[8] = {
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b00000,
};

24
firmware/src/characters.h Normal file
View File

@ -0,0 +1,24 @@
#pragma once
#include <Arduino.h>
#define CHAR_INVERTED_A 0
#define CHAR_INVERTED_B 1
#define CHAR_INVERTED_C 2
#define CHAR_INVERTED_D 3
#define CHAR_ENCODER 4
#define CHAR_ENCODER_SWITCH 5
extern uint8_t invertedA[8];
extern uint8_t invertedB[8];
extern uint8_t invertedC[8];
extern uint8_t invertedD[8];
extern uint8_t encoder[8];
extern uint8_t encoderSwitch[8];
extern uint8_t progressLeftMask[8];
extern uint8_t progressRightMask[8];
extern uint8_t progress0[8];
extern uint8_t progress1[8];
extern uint8_t progress2[8];
extern uint8_t progress3[8];
extern uint8_t progress4[8];
extern uint8_t progress5[8];

View File

@ -9,6 +9,7 @@ I2CScanner scanner;
#include "keyboard.h"
#include "stepper.h"
#include "input.h"
#include "characters.h"
void setupDebug() {
pinMode(LED_BUILTIN, OUTPUT);
@ -50,6 +51,7 @@ char getDebugKey() {
}
void handleDebugFunctions(char key) {
if (key){lcd.write(key);}
if (key == 'h') {
Serial.println("Debug functions:");
Serial.println(" h - print this help");
@ -95,12 +97,12 @@ void handleDebugFunctions(char key) {
quickAccelerate();
} else if (key == '\\') {
lcd.clear();
lcd.write(0);
lcd.write(1);
lcd.write(2);
lcd.write(3);
lcd.write(4);
lcd.write(5);
lcd.write(CHAR_INVERTED_A);
lcd.write(CHAR_INVERTED_B);
lcd.write(CHAR_INVERTED_C);
lcd.write(CHAR_INVERTED_D);
lcd.write(CHAR_ENCODER);
lcd.write(CHAR_ENCODER_SWITCH);
}
}

View File

@ -1,75 +1,10 @@
#include "constants.h"
#include <LCD_I2C.h>
#include <Wire.h>
#include "characters.h"
LCD_I2C lcd(LCD_I2C_ADDR, LCD_COLS, LCD_ROWS);
uint8_t invertedA[8] = {
B11111,
B10001,
B10101,
B10001,
B10101,
B10101,
B11111,
B00000,
};
uint8_t invertedB[8] = {
B11111,
B10011,
B10101,
B10011,
B10101,
B10011,
B11111,
B00000,
};
uint8_t invertedC[8] = {
B11111,
B11001,
B10111,
B10111,
B10111,
B11001,
B11111,
B00000,
};
uint8_t invertedD[8] = {
B11111,
B10011,
B10101,
B10101,
B10101,
B10011,
B11111,
B00000,
};
uint8_t encoder[8] = {
B01110,
B10001,
B00011,
B11000,
B10001,
B01110,
B00000,
B00000,
};
uint8_t encoderSwitch[8] = {
B00000,
B01110,
B10001,
B10101,
B10001,
B01110,
B00000,
B00000,
};
bool setupScreen() {
lcd.begin();
@ -81,11 +16,15 @@ bool setupScreen() {
lcd.backlight();
lcd.clear();
lcd.createChar(0, invertedA);
lcd.createChar(1, invertedB);
lcd.createChar(2, invertedC);
lcd.createChar(3, invertedD);
lcd.createChar(4, encoder);
lcd.createChar(5, encoderSwitch);
// add custom characters to CGROM
// can only add 8 custom characters ,_,
lcd.createChar(CHAR_INVERTED_A, invertedA);
lcd.createChar(CHAR_INVERTED_B, invertedB);
lcd.createChar(CHAR_INVERTED_C, invertedC);
lcd.createChar(CHAR_INVERTED_D, invertedD);
lcd.createChar(CHAR_ENCODER, encoder);
lcd.createChar(CHAR_ENCODER_SWITCH, encoderSwitch);
return true;
}