Skip to content

Commit cfa7c7d

Browse files
committed
v2.1.3 (#5) RP2350 support & minor UI/UX improvements
1 parent 5425aaf commit cfa7c7d

23 files changed

Lines changed: 332 additions & 30 deletions

File tree

include/apps/tools/calc.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
#ifndef CALC_H
22
#define CALC_H
33

4-
#define E 2.71828182845904523536
4+
#include <cstddef>
5+
6+
namespace calc_consts {
7+
static constexpr double CALC_E = 2.71828182845904523536;
8+
}
59

610
#include <string>
711

include/coresys/commands.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
#include "tools/utils.h"
2525
#include "tools/sysinfo.h"
2626
#include "tools/settings.h"
27-
#include <esp_system.h>
28-
#include <WiFi.h>
2927
#include <math.h>
3028
#include <string>
3129
#include <sstream>

include/coresys/config.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,22 @@
2222
#define TFT_RST 4
2323

2424
#define DEVICE_NAME "ESP32-S3"
25+
26+
#elif defined(DEVICE_RP2350)
27+
#define TFT_CS 17
28+
#define TFT_RST 20
29+
#define TFT_DC 26
30+
#define TFT_MOSI 19
31+
#define TFT_SCLK 18
32+
33+
#define DEVICE_NAME "RP-2350"
2534
#else
2635
// Default fallback (ESP32 Standard)
2736
#define TFT_CS 5
2837
#define TFT_DC 2
2938
#define TFT_RST 4
3039
#define DEVICE_NAME "ESP32"
40+
3141
#endif
3242

3343
// #define MAX_Y 230

include/drivers/display.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
#include <Arduino.h>
44
#include <Adafruit_ST7789.h>
55
#include <string>
6+
#if defined(DEVICE_RP2350) && !defined(__FREERTOS)
7+
#define __FREERTOS 1
8+
#endif
69
#include <freertos/FreeRTOS.h>
710
#include <freertos/semphr.h>
811

include/drivers/network.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
#define NETWORK_H
33

44
#include <Arduino.h>
5-
#include <WiFi.h>
6-
#include <HTTPClient.h>
75
#include <string>
86
#include "tools/network_utils.h"
97

8+
#if !defined(DEVICE_RP2350)
9+
#include <WiFi.h>
10+
#endif
1011

1112
extern std::string WIFI_SSID;
1213
extern std::string WIFI_PASS;

include/kernel/kernel.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
#define KERNEL_H
33

44
#include <Arduino.h>
5+
#if defined(DEVICE_RP2350) && !defined(__FREERTOS)
6+
#define __FREERTOS 1
7+
#endif
58
#include <freertos/FreeRTOS.h>
69
#include <freertos/task.h>
710
#include <vector>

platformio.ini

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ lib_deps =
66

77
[common_flags]
88
build_flags =
9-
-DCONFIG_ESP_TASK_WDT_TIMEOUT_S=10
109
-I include
1110
-I include/apps
1211
-I include/coresys
@@ -28,6 +27,7 @@ monitor_speed = 115200
2827

2928
build_flags =
3029
${common_flags.build_flags}
30+
-DCONFIG_ESP_TASK_WDT_TIMEOUT_S=10
3131
-DDEVICE_ESP32_STANDARD
3232

3333
; 240MHz
@@ -45,8 +45,26 @@ monitor_speed = 115200
4545

4646
build_flags =
4747
${common_flags.build_flags}
48+
-DCONFIG_ESP_TASK_WDT_TIMEOUT_S=10
4849
-DDEVICE_ESP32_S3
4950
-DSTS_SPI_SPEED=40000000
5051

5152
; 240MHz
52-
board_build.f_cpu = 240000000L
53+
board_build.f_cpu = 240000000L
54+
55+
[env:waveshare_rp2350_pizero]
56+
platform = raspberrypi
57+
board = waveshare_rp2350_pizero
58+
framework = arduino
59+
60+
lib_deps =
61+
https://github.com/adafruit/Adafruit-ST7735-Library
62+
https://github.com/adafruit/Adafruit-GFX-Library
63+
64+
65+
build_flags =
66+
${common_flags.build_flags}
67+
-DDEVICE_RP2350
68+
-D__FREERTOS=1
69+
-DSTS_SPI_SPEED=40000000
70+
-fexceptions

src/apps/games/coin.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,18 @@
22
#include "coin.h"
33
#include <cstdlib>
44
#include <time.h>
5+
#if !defined(DEVICE_RP2350)
56
#include <esp_random.h>
7+
#endif
8+
9+
static uint32_t getRandom32() {
10+
#if !defined(DEVICE_RP2350)
11+
return esp_random();
12+
#else
13+
return ((uint32_t)std::rand() << 17) ^ ((uint32_t)std::rand() << 2) ^ (uint32_t)(std::rand() & 1);
14+
#endif
15+
}
16+
617
static const int CX = X_MAX / 2;
718
static const int CY = Y_MAX / 2 - 10;
819
static const int R = 80;
@@ -96,13 +107,12 @@ void coinGame() {
96107
}
97108

98109
if (doFlip) {
99-
CoinState state = (CoinState)((esp_random() >> 31) & 1);
110+
CoinState state = (CoinState)((getRandom32() >> 31) & 1);
100111

101112

102113
for (int f = 0; f < 3; f++) {
103114
eraseCoin();
104-
CoinState fake = (CoinState)((esp_random() >> 31) & 1);
105-
drawCoin(fake);
115+
CoinState fake = (CoinState)((getRandom32() >> 31) & 1);
106116
vTaskDelay(65 / portTICK_PERIOD_MS);
107117
}
108118

src/apps/misc/grapher.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include <cmath>
88
#include <string>
99

10-
#define E 2.71828182845904523536
1110

1211
namespace Operation{
1312
/*
@@ -73,8 +72,8 @@ bool evaluateWithX(const std::string& expression, float xValue, float& result) {
7372
}
7473
pos = expr.find("e");
7574
while (pos != std::string::npos) {
76-
expr.replace(pos, 1, std::to_string(E));
77-
pos = expr.find("e", pos + std::to_string(E).length());
75+
expr.replace(pos, 1, std::to_string(calc_consts::CALC_E));
76+
pos = expr.find("e", pos + std::to_string(calc_consts::CALC_E).length());
7877
}
7978

8079
if (expr.length() == 0) {

src/apps/misc/timeutils.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@
77
#include "config.h"
88
#include "pug.h"
99
#include "timeutils.h"
10+
#if !defined(DEVICE_RP2350)
1011
#include <WiFi.h>
1112
#include <HTTPClient.h>
13+
#endif
1214
#include <time.h>
15+
#if defined(DEVICE_RP2350) && !defined(__FREERTOS)
16+
#define __FREERTOS 1
17+
#endif
1318
#include <freertos/FreeRTOS.h>
1419
#include <freertos/task.h>
1520
#include <string>
@@ -18,6 +23,7 @@
1823
Alarm systemAlarm = {false, 0, 0, ""};
1924

2025
void syncTime() {
26+
#if !defined(DEVICE_RP2350)
2127
if (WiFi.status() != WL_CONNECTED) {
2228
printLine("WiFi not connected.");
2329
printLine("Use 'wifi' first.");
@@ -42,6 +48,9 @@ void syncTime() {
4248
printLine("");
4349
printLine("Time sync failed.");
4450
}
51+
#else
52+
printLine("Time sync is not supported on this device.");
53+
#endif
4554

4655
vTaskDelay(pdMS_TO_TICKS(100));
4756
while (Serial.available() > 0) {

0 commit comments

Comments
 (0)