mirror of
https://github.com/erik-toth/audio-synth.git
synced 2025-12-06 15:20:01 +00:00
Software Upload 1
Erste Funktionen zur Firmware erstellt. Keyboard auslesen im Warteschlangen Prinzip. Test-Programm mit 3x4-Matrix Tastatur
This commit is contained in:
62
dev/digital/Firmware_TEST/include/FIRMWARE.h
Normal file
62
dev/digital/Firmware_TEST/include/FIRMWARE.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
@file: FIRMARE.h
|
||||
@author: Erik Tóth
|
||||
@contact: etoth@tsn.at
|
||||
@date: 2025-10-26
|
||||
@brief: Header for FIRMWARE.cpp
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_MCP4728.h>
|
||||
|
||||
#ifndef FIRMWARE_H
|
||||
#define FIRMWARE_H
|
||||
|
||||
#define N_MAX_QUEUE 10
|
||||
#define N_MAX_ROWS 8
|
||||
#define N_MAX_COLS 8
|
||||
#define MS_DEBOUNCE 20
|
||||
|
||||
struct Key
|
||||
{
|
||||
int row;
|
||||
int col;
|
||||
};
|
||||
|
||||
const Key NOT_A_KEY = {-1, -1};
|
||||
|
||||
bool isNotKey(Key k);
|
||||
bool isEqualKey(Key k1, Key k2);
|
||||
|
||||
class Keyboard
|
||||
{
|
||||
public:
|
||||
Keyboard(uint8_t nRows, uint8_t nCols, uint8_t *pinsRow, uint8_t *pinsCol);
|
||||
void begin();
|
||||
void update();
|
||||
int getQueueLength();
|
||||
Key getQueue(uint8_t index);
|
||||
|
||||
private:
|
||||
uint8_t _nRows;
|
||||
uint8_t _nCols;
|
||||
uint8_t *_pinsRow;
|
||||
uint8_t *_pinsCol;
|
||||
|
||||
bool _keyState[N_MAX_COLS][N_MAX_ROWS];
|
||||
bool _keyStateLatest[N_MAX_COLS][N_MAX_ROWS];
|
||||
unsigned long _lastChangeTime[N_MAX_COLS][N_MAX_ROWS];
|
||||
|
||||
Key _activeKeys[N_MAX_QUEUE];
|
||||
uint8_t _nActiveKeys;
|
||||
uint8_t _nSticky;
|
||||
|
||||
void _addActiveKey(uint8_t row, uint8_t col);
|
||||
void _removeActiveKey(uint8_t row, uint8_t col);
|
||||
bool _inQueue(uint8_t row, uint8_t col);
|
||||
bool _inQueue(Key k);
|
||||
bool _isNotKey(Key k);
|
||||
bool _isEqualKey(Key k1, Key k2);
|
||||
};
|
||||
|
||||
#endif
|
||||
29
dev/digital/Firmware_TEST/include/FIRMWARE_DEF.h
Normal file
29
dev/digital/Firmware_TEST/include/FIRMWARE_DEF.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
@file: FIRMARE_DEF.h
|
||||
@author: Erik Tóth
|
||||
@contact: etoth@tsn.at
|
||||
@date: 2025-10-26
|
||||
@brief: Header for constant definitions
|
||||
*/
|
||||
|
||||
#ifndef FIRMWARE_DEF_H
|
||||
#define FIRMWARE_DEF_H
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
// CONSTANTS DEFINITONS
|
||||
#define N_KEYBOARD_ROW 4
|
||||
#define N_KEYBOARD_COL 3
|
||||
#define BAUDRATE 115200
|
||||
// PIN DEFENTITIONS
|
||||
// I2C PINS
|
||||
#define PIN_SDA 15
|
||||
#define PIN_SCL 16
|
||||
// KEYBOARD PINS
|
||||
#define PIN_K_R0 7
|
||||
#define PIN_K_R1 8
|
||||
#define PIN_K_R2 9
|
||||
#define PIN_K_R3 10
|
||||
#define PIN_K_C0 1
|
||||
#define PIN_K_C1 2
|
||||
#define PIN_K_C2 4
|
||||
#endif
|
||||
37
dev/digital/Firmware_TEST/include/README
Normal file
37
dev/digital/Firmware_TEST/include/README
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
This directory is intended for project header files.
|
||||
|
||||
A header file is a file containing C declarations and macro definitions
|
||||
to be shared between several project source files. You request the use of a
|
||||
header file in your project source file (C, C++, etc) located in `src` folder
|
||||
by including it, with the C preprocessing directive `#include'.
|
||||
|
||||
```src/main.c
|
||||
|
||||
#include "header.h"
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Including a header file produces the same results as copying the header file
|
||||
into each source file that needs it. Such copying would be time-consuming
|
||||
and error-prone. With a header file, the related declarations appear
|
||||
in only one place. If they need to be changed, they can be changed in one
|
||||
place, and programs that include the header file will automatically use the
|
||||
new version when next recompiled. The header file eliminates the labor of
|
||||
finding and changing all the copies as well as the risk that a failure to
|
||||
find one copy will result in inconsistencies within a program.
|
||||
|
||||
In C, the convention is to give header files names that end with `.h'.
|
||||
|
||||
Read more about using header files in official GCC documentation:
|
||||
|
||||
* Include Syntax
|
||||
* Include Operation
|
||||
* Once-Only Headers
|
||||
* Computed Includes
|
||||
|
||||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
||||
Reference in New Issue
Block a user