get build working with screen via pico-arduino-compat

This commit is contained in:
2022-06-26 00:22:02 -06:00
parent a5844dae8c
commit a01331d59a
5 changed files with 65 additions and 8 deletions

2
.gitignore vendored
View File

@@ -87,3 +87,5 @@ Temporary Items
# Built Visual Studio Code Extensions # Built Visual Studio Code Extensions
*.vsix *.vsix
# Build directory

5
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,5 @@
{
"cmake.environment": {
"PICO_SDK_PATH":"/Users/mchapman/source/pico/pico-sdk"
},
}

View File

@@ -17,6 +17,9 @@ include(pico_sdk_import.cmake)
project(traegerController C CXX ASM) project(traegerController C CXX ASM)
add_subdirectory(/Users/mchapman/source/pico-arduino-compat/libs/adafruit-gfx-library pac-adafruit-gfx-library)
add_subdirectory(/Users/mchapman/source/pico-arduino-compat/libs/adafruit-sh110x pac-adafruit-sh110x)
# Initialise the Raspberry Pi Pico SDK # Initialise the Raspberry Pi Pico SDK
pico_sdk_init() pico_sdk_init()
@@ -38,7 +41,9 @@ target_link_libraries(traegerController
hardware_spi hardware_spi
hardware_i2c hardware_i2c
hardware_timer hardware_timer
) pac-adafruit-sh110x
pac-adafruit-gfx-library
)
pico_add_extra_outputs(traegerController) pico_add_extra_outputs(traegerController)

View File

@@ -1 +0,0 @@
cmd='/opt/homebrew/Cellar/cmake/3.23.2/bin/cmake;-GUnix Makefiles;<SOURCE_DIR><SOURCE_SUBDIR>'

View File

@@ -1,5 +1,8 @@
#include <stdio.h> #include <stdio.h>
#include "Adafruit_GFX.h"
#include "Adafruit_SH110x.h"
#include "pico/stdlib.h" #include "pico/stdlib.h"
#include "pico/multicore.h"
#include "hardware/spi.h" #include "hardware/spi.h"
#include "hardware/i2c.h" #include "hardware/i2c.h"
#include "hardware/timer.h" #include "hardware/timer.h"
@@ -14,18 +17,25 @@
#define PIN_MOSI 19 #define PIN_MOSI 19
// I2C defines // I2C defines
// This example will use I2C0 on GPIO8 (SDA) and GPIO9 (SCL) running at 400KHz. // This example will use I2C1 on GPIO2 (SDA) and GPIO3 (SCL) running at 400KHz.
// Pins can be changed, see the GPIO function select table in the datasheet for information on GPIO assignments // Pins can be changed, see the GPIO function select table in the datasheet for information on GPIO assignments
#define I2C_PORT i2c0 #define I2C_PORT i2c1
#define I2C_SDA 8 #define I2C_SDA 2
#define I2C_SCL 9 #define I2C_SCL 3
#define BUTTON_A 9
#define BUTTON_B 8
#define BUTTON_C 7
int64_t alarm_callback(alarm_id_t id, void *user_data) { int64_t alarm_callback(alarm_id_t id, void *user_data) {
// Put your timeout handler code in here // Put your timeout handler code in here
return 0; return 0;
} }
void core1_entry()
{
}
int main() int main()
{ {
@@ -41,7 +51,6 @@ int main()
// Chip select is active-low, so we'll initialise it to a driven-high state // Chip select is active-low, so we'll initialise it to a driven-high state
gpio_set_dir(PIN_CS, GPIO_OUT); gpio_set_dir(PIN_CS, GPIO_OUT);
gpio_put(PIN_CS, 1); gpio_put(PIN_CS, 1);
// I2C Initialisation. Using it at 400Khz. // I2C Initialisation. Using it at 400Khz.
i2c_init(I2C_PORT, 400*1000); i2c_init(I2C_PORT, 400*1000);
@@ -50,6 +59,43 @@ int main()
gpio_set_function(I2C_SCL, GPIO_FUNC_I2C); gpio_set_function(I2C_SCL, GPIO_FUNC_I2C);
gpio_pull_up(I2C_SDA); gpio_pull_up(I2C_SDA);
gpio_pull_up(I2C_SCL); gpio_pull_up(I2C_SCL);
gpio_set_dir(BUTTON_A, GPIO_IN);
gpio_set_dir(BUTTON_B, GPIO_IN);
gpio_set_dir(BUTTON_C, GPIO_IN);
gpio_pull_up(BUTTON_A);
gpio_pull_up(BUTTON_B);
gpio_pull_up(BUTTON_C);
Wire1.setSCL(I2C_SCL);
Wire1.setSDA(I2C_SDA);
Adafruit_SH1107 display = Adafruit_SH1107(64, 128, &Wire1);
display.begin(0x3c, true);
display.display();
sleep_ms(1000);
display.setRotation(1);
display.clearDisplay();
display.display();
sleep_ms(500);
display.setTextSize(1);
display.setTextColor(SH110X_WHITE);
display.setCursor(0,0);
display.print("Hello from core 0!");
display.display();
//multicore_launch_core1(core1_entry);
sleep_ms(1000);
while(true)
{
if (gpio_get(BUTTON_A) == false) display.print("A\n");
if (gpio_get(BUTTON_B) == false) display.print("B\n");
if (gpio_get(BUTTON_C) == false) display.print("C\n");
display.display();
sleep_ms(250);
}
// Timer example code - This example fires off the callback after 2000ms // Timer example code - This example fires off the callback after 2000ms
add_alarm_in_ms(2000, alarm_callback, NULL, false); add_alarm_in_ms(2000, alarm_callback, NULL, false);