code cleanup
This commit is contained in:
1 parent
c0b7ec194b
commit
216cdc56a7
5 files changed
+141
-30
No files matched your search
@@ -1,4 +1,6 @@
|
||||
/*
|
||||
* AES256 Seed Phrase Encryptor
|
||||
*
|
||||
* Copyright (C) 2026 SCHAUAUS GmbH
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
@@ -23,8 +25,8 @@
|
||||
// compiler values definition
|
||||
#define PRINT_SERIAL 1
|
||||
#define DEBUG 0
|
||||
#define USE_DISPLAY 1
|
||||
#define HAS_KEYBOARD 0
|
||||
#define USE_DISPLAY 0
|
||||
#define HAS_KEYBOARD 1
|
||||
|
||||
#define BTN_HOME 9
|
||||
|
||||
@@ -36,7 +38,13 @@
|
||||
#include <string.h>
|
||||
|
||||
// project files to include
|
||||
#include "display.h"
|
||||
#if USE_DISPLAY
|
||||
#include "display.h"
|
||||
#endif
|
||||
|
||||
#if HAS_KEYBOARD
|
||||
#include "matrix_keyboard.h"
|
||||
#endif
|
||||
|
||||
//creating an object of AES256 class
|
||||
AES256_ESP aes256;
|
||||
@@ -228,7 +236,10 @@ void encryptData (String data) {
|
||||
#if PRINT_SERIAL
|
||||
Serial.println();
|
||||
#endif
|
||||
|
||||
#if USE_DISPLAY
|
||||
display_crypt_block(fullString, BTN_HOME);
|
||||
#endif
|
||||
}
|
||||
|
||||
void clearCryptograficInformation () {
|
||||
@@ -242,7 +253,9 @@ void clearCryptograficInformation () {
|
||||
Serial.println("Memory cleared");
|
||||
#endif
|
||||
|
||||
#if USE_DISPLAY
|
||||
display_home();
|
||||
#endif
|
||||
}
|
||||
|
||||
void restartDevice () {
|
||||
@@ -299,7 +312,20 @@ void setup() {
|
||||
Serial.begin(115200);
|
||||
while(!Serial);
|
||||
pinMode(BTN_HOME, INPUT);
|
||||
|
||||
#if USE_DISPLAY
|
||||
display_setup();
|
||||
#endif
|
||||
|
||||
#if HAS_KEYBOARD
|
||||
initKeyboard();
|
||||
#endif
|
||||
pinMode(4, OUTPUT);
|
||||
pinMode(5, OUTPUT);
|
||||
digitalWrite(4, 0);
|
||||
digitalWrite(5, 0);
|
||||
pinMode(4, INPUT_PULLDOWN);
|
||||
|
||||
Serial.println("Waiting for command");
|
||||
#if PRINT_SERIAL
|
||||
Serial.println("send \"help\" for available commands");
|
||||
@@ -309,4 +335,8 @@ void setup() {
|
||||
void loop() {
|
||||
readCmd();
|
||||
readHome(); // check for Home-button being pressed
|
||||
#if HAS_KEYBOARD
|
||||
char keyRead = readKeyboard();
|
||||
if(keyRead != '\0') Serial.print("Keyboard input: " + keyRead + '\0');
|
||||
#endif
|
||||
}
|
||||
+37
@@ -1,6 +1,43 @@
|
||||
/*
|
||||
* AES256 Seed Phrase Encryptor
|
||||
*
|
||||
* Copyright (C) 2026 SCHAUAUS GmbH
|
||||
*
|
||||
*/
|
||||
|
||||
// genereal definitions
|
||||
#define DEBUG_DISPLAY 1
|
||||
|
||||
// pin definition
|
||||
#define TFT_CS 14
|
||||
#define TFT_DC 15
|
||||
#define TFT_IPS true
|
||||
#define TFT_MISO -1
|
||||
#define TFT_MOSI 6
|
||||
#define TFT_RST 21
|
||||
#define TFT_SCK 7
|
||||
#define TFT_BKL 22
|
||||
#define RGB_LED 8
|
||||
|
||||
// display dimensions ESP32-C6-LCD1.47 is portrait by default
|
||||
#define TFT_HEIGHT 320
|
||||
#define TFT_WIDTH 172
|
||||
#define TFT_COL_OFFSET 34 // offset needed due to organization of ST7789 VRAM
|
||||
#define TFT_ROW_OFFSET 0 // offset needed due to organization of ST7789 VRAM
|
||||
|
||||
// set display rotation (needs to be 0 for offsets to be applied properly!)
|
||||
#define TFT_ROTATION 0
|
||||
|
||||
// backlight settings
|
||||
#define TFT_BKL_DUTY 50
|
||||
|
||||
#include <sys/_stdint.h>
|
||||
#include <sys/_types.h>
|
||||
#include "pins_arduino.h"
|
||||
|
||||
//#include <U8g2lib.h>
|
||||
#include <Arduino_GFX_Library.h>
|
||||
|
||||
#include "display.h"
|
||||
|
||||
Arduino_DataBus *bus = new Arduino_HWSPI( TFT_DC, TFT_CS);
|
||||
|
||||
@@ -1,30 +1,9 @@
|
||||
//#include <U8g2lib.h>
|
||||
#include <Arduino_GFX_Library.h>
|
||||
|
||||
#define DEBUG_DISPLAY 0
|
||||
|
||||
// pin definition
|
||||
#define TFT_CS 14
|
||||
#define TFT_DC 15
|
||||
#define TFT_IPS true
|
||||
#define TFT_MISO -1
|
||||
#define TFT_MOSI 6
|
||||
#define TFT_RST 21
|
||||
#define TFT_SCK 7
|
||||
#define TFT_BKL 22
|
||||
#define RGB_LED 8
|
||||
|
||||
// display dimensions ESP32-C6-LCD1.47 is portrait by default
|
||||
#define TFT_HEIGHT 320
|
||||
#define TFT_WIDTH 172
|
||||
#define TFT_COL_OFFSET 34 // offset needed due to organization of ST7789 VRAM
|
||||
#define TFT_ROW_OFFSET 0 // offset needed due to organization of ST7789 VRAM
|
||||
|
||||
// set display rotation (needs to be 0 for offsets to be applied properly!)
|
||||
#define TFT_ROTATION 0
|
||||
|
||||
// backlight settings
|
||||
#define TFT_BKL_DUTY 50
|
||||
/*
|
||||
* AES256 Seed Phrase Encryptor
|
||||
*
|
||||
* Copyright (C) 2026 SCHAUAUS GmbH
|
||||
*
|
||||
*/
|
||||
|
||||
void display_setup();
|
||||
void display_help();
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
#include <Arduino.h>
|
||||
#include <iterator>
|
||||
#include "esp32-hal-gpio.h"
|
||||
/*
|
||||
* AES256 Seed Phrase Encryptor
|
||||
*
|
||||
* Copyright (C) 2026 SCHAUAUS GmbH
|
||||
*
|
||||
*/
|
||||
|
||||
// pin definitions
|
||||
#define KEYBOARD_COL1_PIN 1
|
||||
#define KEYBOARD_COL2_PIN 2
|
||||
#define KEYBOARD_COL3_PIN 3
|
||||
#define KEYBOARD_COL4_PIN 0
|
||||
#define KEYBOARD_COL5_PIN 5
|
||||
|
||||
#define KEYBOARD_ROW1_PIN 18
|
||||
#define KEYBOARD_ROW2_PIN 19
|
||||
#define KEYBOARD_ROW3_PIN 20
|
||||
#define KEYBOARD_ROW4_PIN 23
|
||||
|
||||
// project includes
|
||||
#include "matrix_keyboard.h"
|
||||
|
||||
char keyboardCharacters[] = "0123456789ABCDEF<OX>";
|
||||
int colPins[] = { KEYBOARD_COL1_PIN, KEYBOARD_COL2_PIN, KEYBOARD_COL3_PIN, KEYBOARD_COL4_PIN };
|
||||
int rowPins[] = { KEYBOARD_ROW1_PIN, KEYBOARD_ROW2_PIN, KEYBOARD_ROW3_PIN, KEYBOARD_ROW4_PIN };
|
||||
|
||||
void initKeyboard () {
|
||||
// set column pins as input pulled low
|
||||
for ( int i = 0; i < sizeof(colPins) / sizeof(colPins[0]); i++ )
|
||||
pinMode(colPins[i], INPUT_PULLDOWN);
|
||||
|
||||
//set row pins as output
|
||||
for ( int j = 0; j < sizeof(rowPins) / sizeof(rowPins[0]); j++ ) {
|
||||
pinMode(rowPins[j], OUTPUT);
|
||||
digitalWrite(rowPins[j], 0);
|
||||
}
|
||||
}
|
||||
|
||||
char readKeyboard () {
|
||||
for ( int i = 0; i < sizeof(rowPins) / sizeof(rowPins[0]); i++ ) { // walk through each row of keys on the matrix keyboard
|
||||
digitalWrite(rowPins[i], 1);
|
||||
delay(100);
|
||||
for ( int j = 0; j < sizeof(colPins) / sizeof(colPins[0]); j++ ) { // read each column of the keyboard to identify a pressed key
|
||||
if ( digitalRead( colPins[j] ) ) { // check if button is pressed
|
||||
while ( digitalRead( colPins[j] ) ); // wait until button is released again
|
||||
digitalWrite(rowPins[i], 0);
|
||||
return keyboardCharacters[i*4 + j]; // return key
|
||||
}
|
||||
}
|
||||
digitalWrite(rowPins[i], 0);
|
||||
}
|
||||
return '\0';
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
* AES256 Seed Phrase Encryptor
|
||||
*
|
||||
* Copyright (C) 2026 SCHAUAUS GmbH
|
||||
*
|
||||
*/
|
||||
|
||||
void initKeyboard ();
|
||||
char readKeyboard ();
|
||||
Reference in new issue
Block a user