summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile56
-rw-r--r--boards.h288
-rw-r--r--main.ino73
3 files changed, 417 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..564aac6
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,56 @@
+BUILD_DIR = $(CURDIR)/.build
+
+OPTS_HARDWARE = -hardware /usr/share/arduino/hardware -hardware /home/jonas/.arduino15/packages
+OPTS_TOOLS = -tools /usr/share/arduino/hardware/tools/avr -tools /home/jonas/.arduino15/packages
+OPTS_LIBS = -libraries /home/jonas/Arduino/libraries
+FQBN = -fqbn=esp32:esp32:esp32:JTAGAdapter=default,PSRAM=disabled,PartitionScheme=default,CPUFreq=240,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,LoopCore=1,EventsCore=1,DebugLevel=none,EraseFlash=none
+
+all: build upload
+
+build:
+ rm -rf .build
+ mkdir --parents .build .cache
+ arduino-builder -compile -logger=machine \
+ $(OPTS_HARDWARE) $(OPTS_TOOLS) $(OPTS_LIBS) $(FQBN) \
+ -ide-version=10819 -build-path $(BUILD_DIR) -warnings=none -build-cache $(CURDIR)/.cache \
+ -prefs=build.warn_data_percentage=75 \
+ -prefs=runtime.tools.riscv32-esp-elf-gcc.path=/home/jonas/.arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/esp-2021r2-patch5-8.4.0 \
+ -prefs=runtime.tools.riscv32-esp-elf-gcc-esp-2021r2-patch5-8.4.0.path=/home/jonas/.arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/esp-2021r2-patch5-8.4.0 \
+ -prefs=runtime.tools.esptool_py.path=/home/jonas/.arduino15/packages/esp32/tools/esptool_py/4.5.1 \
+ -prefs=runtime.tools.esptool_py-4.5.1.path=/home/jonas/.arduino15/packages/esp32/tools/esptool_py/4.5.1 \
+ -prefs=runtime.tools.mkspiffs.path=/home/jonas/.arduino15/packages/esp32/tools/mkspiffs/0.2.3 \
+ -prefs=runtime.tools.mkspiffs-0.2.3.path=/home/jonas/.arduino15/packages/esp32/tools/mkspiffs/0.2.3 \
+ -prefs=runtime.tools.xtensa-esp32-elf-gcc.path=/home/jonas/.arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-2021r2-patch5-8.4.0 \
+ -prefs=runtime.tools.xtensa-esp32-elf-gcc-esp-2021r2-patch5-8.4.0.path=/home/jonas/.arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-2021r2-patch5-8.4.0 \
+ -prefs=runtime.tools.xtensa-esp32s3-elf-gcc.path=/home/jonas/.arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0 \
+ -prefs=runtime.tools.xtensa-esp32s3-elf-gcc-esp-2021r2-patch5-8.4.0.path=/home/jonas/.arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0 \
+ -prefs=runtime.tools.xtensa-esp-elf-gdb.path=/home/jonas/.arduino15/packages/esp32/tools/xtensa-esp-elf-gdb/11.2_20220823 \
+ -prefs=runtime.tools.xtensa-esp-elf-gdb-11.2_20220823.path=/home/jonas/.arduino15/packages/esp32/tools/xtensa-esp-elf-gdb/11.2_20220823 \
+ -prefs=runtime.tools.riscv32-esp-elf-gdb.path=/home/jonas/.arduino15/packages/esp32/tools/riscv32-esp-elf-gdb/11.2_20220823 \
+ -prefs=runtime.tools.riscv32-esp-elf-gdb-11.2_20220823.path=/home/jonas/.arduino15/packages/esp32/tools/riscv32-esp-elf-gdb/11.2_20220823 \
+ -prefs=runtime.tools.dfu-util.path=/home/jonas/.arduino15/packages/arduino/tools/dfu-util/0.11.0-arduino5 \
+ -prefs=runtime.tools.dfu-util-0.11.0-arduino5.path=/home/jonas/.arduino15/packages/arduino/tools/dfu-util/0.11.0-arduino5 \
+ -prefs=runtime.tools.xtensa-esp32s2-elf-gcc.path=/home/jonas/.arduino15/packages/esp32/tools/xtensa-esp32s2-elf-gcc/esp-2021r2-patch5-8.4.0 \
+ -prefs=runtime.tools.xtensa-esp32s2-elf-gcc-esp-2021r2-patch5-8.4.0.path=/home/jonas/.arduino15/packages/esp32/tools/xtensa-esp32s2-elf-gcc/esp-2021r2-patch5-8.4.0 \
+ -prefs=runtime.tools.mklittlefs.path=/home/jonas/.arduino15/packages/esp32/tools/mklittlefs/3.0.0-gnu12-dc7f933 \
+ -prefs=runtime.tools.mklittlefs-3.0.0-gnu12-dc7f933.path=/home/jonas/.arduino15/packages/esp32/tools/mklittlefs/3.0.0-gnu12-dc7f933 \
+ -prefs=runtime.tools.openocd-esp32.path=/home/jonas/.arduino15/packages/esp32/tools/openocd-esp32/v0.12.0-esp32-20230419 \
+ -prefs=runtime.tools.openocd-esp32-v0.12.0-esp32-20230419.path=/home/jonas/.arduino15/packages/esp32/tools/openocd-esp32/v0.12.0-esp32-20230419 \
+ -verbose \
+ $(CURDIR)/main.ino
+
+clear_cache:
+ rm -rf .cache
+
+#arduino-builder -compile -logger=machine -hardware /usr/share/arduino/hardware -hardware /home/jonas/.arduino15/packages -tools /usr/share/arduino/hardware/tools/avr -tools /home/jonas/.arduino15/packages -libraries /home/jonas/Arduino/libraries -fqbn=esp32:esp32:esp32:JTAGAdapter=default,PSRAM=disabled,PartitionScheme=default,CPUFreq=240,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,LoopCore=1,EventsCore=1,DebugLevel=none,EraseFlash=none -vid-pid=10C4_EA60 -ide-version=10819 -build-path /tmp/arduino_build_48694 -warnings=none -build-cache /tmp/arduino_cache_282410 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.riscv32-esp-elf-gcc.path=/home/jonas/.arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.riscv32-esp-elf-gcc-esp-2021r2-patch5-8.4.0.path=/home/jonas/.arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.esptool_py.path=/home/jonas/.arduino15/packages/esp32/tools/esptool_py/4.5.1 -prefs=runtime.tools.esptool_py-4.5.1.path=/home/jonas/.arduino15/packages/esp32/tools/esptool_py/4.5.1 -prefs=runtime.tools.mkspiffs.path=/home/jonas/.arduino15/packages/esp32/tools/mkspiffs/0.2.3 -prefs=runtime.tools.mkspiffs-0.2.3.path=/home/jonas/.arduino15/packages/esp32/tools/mkspiffs/0.2.3 -prefs=runtime.tools.xtensa-esp32-elf-gcc.path=/home/jonas/.arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.xtensa-esp32-elf-gcc-esp-2021r2-patch5-8.4.0.path=/home/jonas/.arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.xtensa-esp32s3-elf-gcc.path=/home/jonas/.arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.xtensa-esp32s3-elf-gcc-esp-2021r2-patch5-8.4.0.path=/home/jonas/.arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.xtensa-esp-elf-gdb.path=/home/jonas/.arduino15/packages/esp32/tools/xtensa-esp-elf-gdb/11.2_20220823 -prefs=runtime.tools.xtensa-esp-elf-gdb-11.2_20220823.path=/home/jonas/.arduino15/packages/esp32/tools/xtensa-esp-elf-gdb/11.2_20220823 -prefs=runtime.tools.riscv32-esp-elf-gdb.path=/home/jonas/.arduino15/packages/esp32/tools/riscv32-esp-elf-gdb/11.2_20220823 -prefs=runtime.tools.riscv32-esp-elf-gdb-11.2_20220823.path=/home/jonas/.arduino15/packages/esp32/tools/riscv32-esp-elf-gdb/11.2_20220823 -prefs=runtime.tools.dfu-util.path=/home/jonas/.arduino15/packages/arduino/tools/dfu-util/0.11.0-arduino5 -prefs=runtime.tools.dfu-util-0.11.0-arduino5.path=/home/jonas/.arduino15/packages/arduino/tools/dfu-util/0.11.0-arduino5 -prefs=runtime.tools.xtensa-esp32s2-elf-gcc.path=/home/jonas/.arduino15/packages/esp32/tools/xtensa-esp32s2-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.xtensa-esp32s2-elf-gcc-esp-2021r2-patch5-8.4.0.path=/home/jonas/.arduino15/packages/esp32/tools/xtensa-esp32s2-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.mklittlefs.path=/home/jonas/.arduino15/packages/esp32/tools/mklittlefs/3.0.0-gnu12-dc7f933 -prefs=runtime.tools.mklittlefs-3.0.0-gnu12-dc7f933.path=/home/jonas/.arduino15/packages/esp32/tools/mklittlefs/3.0.0-gnu12-dc7f933 -prefs=runtime.tools.openocd-esp32.path=/home/jonas/.arduino15/packages/esp32/tools/openocd-esp32/v0.12.0-esp32-20230419 -prefs=runtime.tools.openocd-esp32-v0.12.0-esp32-20230419.path=/home/jonas/.arduino15/packages/esp32/tools/openocd-esp32/v0.12.0-esp32-20230419 -verbose /home/jonas/Arduino/sketch_oct06b/sketch_oct06b.ino
+
+
+upload:
+ python3 /home/jonas/.arduino15/packages/esp32/tools/esptool_py/4.5.1/esptool.py \
+ --chip esp32 --port /dev/ttyUSB0 --baud 921600 \
+ --before default_reset --after hard_reset write_flash \
+ -z --flash_mode dio --flash_freq 80m --flash_size 4MB \
+ 0x1000 $(BUILD_DIR)/main.ino.bootloader.bin \
+ 0x8000 $(BUILD_DIR)/main.ino.partitions.bin \
+ 0xe000 /home/jonas/.arduino15/packages/esp32/hardware/esp32/2.0.14/tools/partitions/boot_app0.bin \
+ 0x10000 $(BUILD_DIR)/main.ino.bin
diff --git a/boards.h b/boards.h
new file mode 100644
index 0000000..153a650
--- /dev/null
+++ b/boards.h
@@ -0,0 +1,288 @@
+
+#pragma once
+
+#if defined(LILYGO_T5_V213)
+
+#define EPD_MOSI (23)
+#define EPD_MISO (-1)
+#define EPD_SCLK (18)
+#define EPD_CS (5)
+
+#define EPD_BUSY (4)
+#define EPD_RSET (16)
+#define EPD_DC (17)
+
+#define SDCARD_CS (13)
+#define SDCARD_MOSI (15)
+#define SDCARD_MISO (2)
+#define SDCARD_SCLK (14)
+
+#define BUTTON_1 (39)
+#define BUTTONS {39}
+
+#define BUTTON_COUNT (1)
+
+#define LED_PIN (19)
+#define LED_ON (LOW)
+
+#define ADC_PIN (35)
+
+#define _HAS_ADC_DETECTED_
+#define _HAS_LED_
+#define _HAS_SDCARD_
+
+#elif defined(LILYGO_T5_V22)
+
+#define EPD_MOSI (23)
+#define EPD_MISO (2)
+#define EPD_SCLK (18)
+#define EPD_CS (5)
+
+#define EPD_BUSY (4)
+#define EPD_RSET (12)
+#define EPD_DC (19)
+
+#define SDCARD_CS (13)
+
+#define BUTTON_1 (37)
+#define BUTTON_2 (38)
+#define BUTTON_3 (39)
+
+#define BUTTONS {37,38,39}
+#define BUTTON_COUNT (3)
+
+#define LED_PIN (26)
+#define LED_ON (HIGH)
+
+#define ADC_PIN (35)
+
+#define SPERKER_PIN (25)
+
+#define LEDC_CHANNEL_0 (0)
+#define _HAS_ADC_DETECTED_
+#define _HAS_LED_
+#define _HAS_SPEAKER_
+#define _BUILTIN_DAC_
+#define _USE_SHARED_SPI_BUS_
+#define _HAS_SDCARD_
+
+#elif defined(LILYGO_T5_V24)
+
+#define EPD_MOSI (23)
+#define EPD_MISO (-1) //elink no use
+#define EPD_SCLK (18)
+
+#define EPD_BUSY (4)
+#define EPD_RSET (16)
+#define EPD_DC (17)
+#define EPD_CS (5)
+
+#define SDCARD_CS (13)
+#define SDCARD_MOSI (15)
+#define SDCARD_MISO (2)
+#define SDCARD_SCLK (14)
+
+#define BUTTON_1 (37)
+#define BUTTON_2 (38)
+#define BUTTON_3 (39)
+
+#define SPK_POWER_EN (19)
+
+#define BUTTONS {37,38,39}
+#define BUTTON_COUNT (3)
+
+#define LED_PIN (26)
+#define LED_ON (LOW)
+
+#define ADC_PIN (35)
+
+#define SPERKER_PIN (25)
+
+#define LEDC_CHANNEL_0 (0)
+#define _HAS_ADC_DETECTED_
+#define _HAS_LED_
+#define _HAS_SPEAKER_
+#define _BUILTIN_DAC_
+#define _HAS_SDCARD_
+#define _HAS_PWR_CTRL_
+#elif defined(LILYGO_T5_V28)
+
+#define EPD_MOSI (23)
+#define EPD_MISO (-1)
+#define EPD_SCLK (18)
+#define EPD_CS (5)
+
+#define EPD_BUSY (4)
+#define EPD_RSET (16)
+#define EPD_DC (17)
+
+#define SDCARD_CS (13)
+#define SDCARD_MOSI (15)
+#define SDCARD_MISO (2)
+#define SDCARD_SCLK (14)
+
+#define BUTTON_1 (37)
+#define BUTTON_2 (38)
+#define BUTTON_3 (39)
+
+#define IIS_WS (25)
+#define IIS_BCK (26)
+#define IIS_DOUT (19)
+
+#define ICS43434_WS (33)
+#define ICS43434_BCK (32)
+#define ICS43434_DIN (27)
+
+#define I2C_SDA (21)
+#define I2C_SCL (22)
+
+#define BUTTONS {37,38,39}
+#define BUTTON_COUNT (3)
+
+#define LED_PIN (22)
+#define LED_ON (HIGH)
+
+#define ADC_PIN (35)
+
+#define _HAS_ADC_DETECTED_
+#define _HAS_LED_
+// #define _HAS_SPEAKER_
+#define _HAS_SDCARD_
+
+
+#elif defined(LILYGO_T5_V102)
+
+#define EPD_MOSI (21)
+#define EPD_MISO (-1)
+#define EPD_SCLK (22)
+#define EPD_CS (5)
+
+#define EPD_BUSY (34)
+#define EPD_RSET (4)
+#define EPD_DC (19)
+
+#define EPD_POWER_ENABLE (27)
+
+#define SDCARD_CS (13)
+#define SDCARD_MOSI (15)
+#define SDCARD_MISO (2)
+#define SDCARD_SCLK (14)
+
+#define BUTTON_1 (36)
+#define BUTTON_2 (39)
+#define BUTTON_3 (0u)
+#define BUTTONS {36,39,0}
+#define BUTTON_COUNT (3)
+
+
+#define ADC_PIN (35)
+
+#define _HAS_ADC_DETECTED_
+#define _HAS_SDCARD_
+
+
+
+#elif defined(LILYGO_T5_V266)
+
+#define EPD_MOSI (23)
+#define EPD_MISO (-1)
+#define EPD_SCLK (18)
+#define EPD_CS (5)
+
+#define EPD_BUSY (34)
+#define EPD_RSET (4)
+#define EPD_DC (19)
+
+#define SDCARD_CS (13)
+#define SDCARD_MOSI (15)
+#define SDCARD_MISO (2)
+#define SDCARD_SCLK (14)
+
+#define BUTTON_1 (39)
+#define BUTTONS {39}
+
+#define BUTTON_COUNT (1)
+
+#define LED_PIN (12)
+#define LED_ON (LOW)
+
+#define ADC_PIN (35)
+
+#define _HAS_ADC_DETECTED_
+#define _HAS_LED_
+#define _HAS_SDCARD_
+
+#elif defined(LILYGO_EPD_DISPLAY)
+
+#define EPD_MOSI (21)
+#define EPD_MISO (-1)
+#define EPD_SCLK (22)
+#define EPD_CS (5)
+
+#define EPD_BUSY (18)
+#define EPD_RSET (23)
+#define EPD_DC (19)
+
+#define EPD_POWER_ENABLE (14)
+
+#define BUTTON_1 (35)
+#define BUTTON_COUNT (1)
+
+#define ADC_PIN (34)
+#define RGB_STRIP_PIN (4)
+#define RGB_STRIP_COUNT (1)
+
+#define _HAS_ADC_DETECTED_
+#define _HAS_POWER_CONTROL_
+#define _HAS_RGB_PIXEL_
+
+#elif defined(LILYGO_EPD_DISPLAY_154)
+
+
+#define EPD_MOSI (13)
+#define EPD_MISO (-1)
+#define EPD_SCLK (14)
+#define EPD_CS (15)
+
+#define EPD_BUSY (16)
+#define EPD_RSET (17)
+#define EPD_DC (2)
+#define EPD_BACKLIGHT_PIN (0)
+
+#define EPD_POWER_ENABLE (5)
+
+#define BUTTON_1 (35)
+#define BUTTON_COUNT (1)
+
+#define ADC_PIN (34)
+#define MOTOR_PIN (4)
+
+#define GPS_TX_PIN (22)
+#define GPS_RX_PIN (21)
+#define GPS_1PPS_PIN (19)
+#define GPS_RESET_PIN (23)
+#define GPS_WAKEUP_PIN (18)
+
+#define _HAS_ADC_DETECTED_
+#define _HAS_POWER_CONTROL_
+#define _HAS_GPS_
+
+#elif defined(LILYGO_TBLOCK)
+
+#define EPD_MOSI (23)
+#define EPD_MISO (-1)
+#define EPD_SCLK (18)
+#define EPD_CS (5)
+
+#define EPD_BUSY (38)
+#define EPD_RSET (27)
+#define EPD_DC (19)
+
+#define BUTTON_1 (36)
+#define BUTTON_COUNT (1)
+
+#define _HAS_RTC_
+
+#else
+#error "Please select model !!!"
+#endif \ No newline at end of file
diff --git a/main.ino b/main.ino
new file mode 100644
index 0000000..62f755a
--- /dev/null
+++ b/main.ino
@@ -0,0 +1,73 @@
+// Pill dispenser
+
+// Inspired by article "Blink Without Delay"
+// https://docs.arduino.cc/built-in-examples/digital/BlinkWithoutDelay
+
+// Inspired by basic usage documentation of GEM library
+// https://github.com/Spirik/GEM
+
+#include <Button.h>
+
+// assume that any ESP32 board is a Lilygo T5 V2.2
+#if defined(ESP32)
+#define LILYGO_T5_V22
+#endif
+
+// use built-in buttons and LEDs when possible
+#if defined(LILYGO_T5_V22)
+#include "boards.h"
+const byte movePin = BUTTON_1;
+const byte selectPin = BUTTON_1;
+const int statusPin = LED_PIN;
+#else
+const byte movePin = 2;
+const byte selectPin = 3;
+const int statusPin = LED_BUILTIN; // pin 13 is built-in LED on many Arduino boards
+#endif
+
+Button button1(movePin); // Connect between pin 2 and GND
+
+int i = 0;
+
+void setup() {
+ button1.begin();
+
+ // put your setup code here, to run once:
+ Serial.begin(115200);
+
+ // Emit actions on pin #3
+ pinMode(13, OUTPUT);
+}
+
+void loop() {
+ // put your main code here, to run repeatedly:
+
+ // læs om der bliver trykket på knappen
+ // hvis der trykes - så udfør noget. (her vis tekst på skærm)
+ if (button1.pressed()) {
+ Serial.println("action requested!");
+ }
+
+ //Hvis ovenstående sker, så giv output i pin #3 (evt lys) - her blinker den.
+ if (i < 8) {
+ digitalWrite(13, LOW);
+ i++;
+ } else {
+ digitalWrite(13, HIGH);
+ i = 0;
+ }
+ delay(100);
+
+ //Næste trin skal vi have den til at aflæse knappen igen.
+ if (button1.pressed()) {
+ Serial.println("hvilken borger?");
+ digitalWrite(13, HIGH);
+ while (true) {
+ delay(100);
+ if (button1.pressed()) {
+ Serial.println("stoooop!");
+ break;
+ }
+ }
+ }
+}