first commit

This commit is contained in:
jaksatomovic 2024-03-06 12:40:28 +01:00
commit 868b14f8c8
286 changed files with 59925 additions and 0 deletions

39
include/README Normal file
View file

@ -0,0 +1,39 @@
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 usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.
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

62
include/clickwheel.h Normal file
View file

@ -0,0 +1,62 @@
#ifndef CLICKWHEEL_H
#define CLICKWHEEL_H
#include <Arduino.h>
////////Start Click Wheel
#define CENTER_BUTTON_BIT 7
#define LEFT_BUTTON_BIT 9
#define RIGHT_BUTTON_BIT 8
#define UP_BUTTON_BIT 11
#define DOWN_BUTTON_BIT 10
#define WHEEL_TOUCH_BIT 29
#define BUFFER_SIZE 3
#define BUTTON_INDEX 0
#define BUTTON_STATE_INDEX 1
#define WHEEL_POSITION_INDEX 2
#define CLOCK_PIN 4 // SCL purple
#define DATA_PIN 3 // SDA grey
#define BUTTON_PIN_BITMASK 0x200000000 // 2^33 in hex
#define BIT_COUNT 32
bool ClickWheelClicked = false;
int ClickWheelScrollPrev[5];
int ClickWheelNoiseFilterAmt = 4; // three works for me!
volatile bool CLOCK_RISING = false;
volatile bool DATA_EDGE = false;
// Click Wheel Data Line Pin Bitmask
int wheel_position;
int last_wheel_position;
int last_button;
int last_interaction;
bool wheel_scroll_lift = false;
int WheelSensitivity = 0;
unsigned long crashtick = 0;
volatile boolean click_wheel_packets_received = false;
volatile int HapticFeebackDue = 0;
// used to store the current packet
uint32_t bits = 0;
// used to store the previous full packet
uint32_t lastBits = 0;
uint8_t bitIndex = 0;
uint8_t oneCount = 0;
uint8_t recording = 0;
// indicates whether the data pin is high or low
uint8_t dataBit = 1;
uint8_t lastPosition = 255;
int hapticWaveId = -1;
char buttons[] = {CENTER_BUTTON_BIT, LEFT_BUTTON_BIT, RIGHT_BUTTON_BIT,
UP_BUTTON_BIT, DOWN_BUTTON_BIT, WHEEL_TOUCH_BIT};
const uint32_t PACKET_START = 0b01101;
char buffer[BUFFER_SIZE];
char prev_buffer[BUFFER_SIZE];
volatile bool InputReceived = false;
#endif

7
include/constants.h Normal file
View file

@ -0,0 +1,7 @@
#ifndef CONSTANTS_H
#define CONSTANTS_H
#define FONT_SEMIBOLD "Baloo2-SemiBold-26"
#define FONT_BOLD "Baloo2-Bold-26"
#endif // CONSTANTS_H

13
include/main_header.h Normal file
View file

@ -0,0 +1,13 @@
#ifndef MAIN_HEADER_H
#define MAIN_HEADER_H
#include <Arduino.h>
#include <TFT_eSPI.h>
#include <Button2.h>
// Local imports
#include "pins.h"
#include "constants.h"
#include "clickwheel.h"
#endif // MAIN_HEADER_H

14
include/pins.h Normal file
View file

@ -0,0 +1,14 @@
#ifndef PINS_H
#define PINS_H
#define BUTTON_PIN 12
#define NEOPIXEL_PIN 33
//------------------
// CLICKWHEEL
//------------------
#define CLOCK_PIN 4 // SCL purple
#define DATA_PIN 3 // SDA grey
#endif // PINS_H