Great work!
In case if anyone wants to try this lua with sound on Pico 1 for PicoCalc
here is the pre-compiled version based on the commit hash
847aa1778607de66a3533b2ed62a2259816f1b1f
uf2 file:
multi boot bin file:
and here is the patch I’ve made:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fcc867f..cbe27c1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,7 +12,7 @@ if (EXISTS ${picoVscode})
include(${picoVscode})
endif()
# ====================================================================================
-set(PICO_BOARD pico2 CACHE STRING "Board type")
+set(PICO_BOARD pico CACHE STRING "Board type")
cmake_minimum_required(VERSION 3.13)
diff --git a/drivers/keyboard.c b/drivers/keyboard.c
index 344755a..2044924 100644
--- a/drivers/keyboard.c
+++ b/drivers/keyboard.c
@@ -11,7 +11,7 @@
#define KBD_MOD i2c1
#define KBD_SDA 6
#define KBD_SCL 7
-#define KBD_SPEED 20000 // if dual i2c, then the speed of keyboard i2c should be 10khz
+#define KBD_SPEED 10000 // if dual i2c, then the speed of keyboard i2c should be 10khz
#define KBD_ADDR 0x1F
// Commands defined by the keyboard driver
@@ -31,7 +31,7 @@ enum {
REG_ID_C64_JS = 0x0d, // joystick io bits
};
-#define I2C_TIMEOUT 10000
+#define I2C_TIMEOUT 50000
volatile atomic_bool i2c_in_use = false;
#define KEY_COUNT 256
@@ -54,7 +54,7 @@ static int keyboard_modifiers;
static int i2c_kbd_write(unsigned char* data, int size) {
if (atomic_load(&i2c_in_use) == true) return 0;
atomic_store(&i2c_in_use, true);
- int retval = i2c_write_timeout_us(KBD_MOD, KBD_ADDR, data, size, false, I2C_TIMEOUT * size);
+ int retval = i2c_write_timeout_us(KBD_MOD, KBD_ADDR, data, size, false, I2C_TIMEOUT );
atomic_store(&i2c_in_use, false);
if (retval == PICO_ERROR_GENERIC || retval == PICO_ERROR_TIMEOUT) {
printf("i2c_kbd_write: i2c write error\n");
@@ -66,7 +66,7 @@ static int i2c_kbd_write(unsigned char* data, int size) {
static int i2c_kbd_read(unsigned char* data, int size) {
if (atomic_load(&i2c_in_use) == true) return 0;
atomic_store(&i2c_in_use, true);
- int retval = i2c_read_timeout_us(KBD_MOD, KBD_ADDR, data, size, false, I2C_TIMEOUT * size);
+ int retval = i2c_read_timeout_us(KBD_MOD, KBD_ADDR, data, size, false, I2C_TIMEOUT);
atomic_store(&i2c_in_use, false);
if (retval == PICO_ERROR_GENERIC || retval == PICO_ERROR_TIMEOUT) {
printf("i2c_kbd_read: i2c read error\n");
@@ -216,4 +216,4 @@ int get_battery(bool* charging) {
result >>= 8;
if (charging) *charging = (result & 1<<7) != 0;
return result & ~(1<<7);
-}
\ No newline at end of file
+}