Fix OLED working on second core, add Traeger logo
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
#include "hardware/i2c.h"
|
||||
#include "hardware/timer.h"
|
||||
|
||||
#include "traegerLogo.h"
|
||||
|
||||
// SPI Defines
|
||||
// We are going to use SPI 0, and allocate it to the following GPIO pins
|
||||
// Pins can be changed, see the GPIO function select table in the datasheet for information on GPIO assignments
|
||||
@@ -32,29 +34,11 @@ int64_t alarm_callback(alarm_id_t id, void *user_data) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void core1_entry()
|
||||
[[noreturn]] void core1_entry()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
stdio_init_all();
|
||||
|
||||
// SPI initialisation. This example will use SPI at 1MHz.
|
||||
spi_init(SPI_PORT, 1000*1000);
|
||||
gpio_set_function(PIN_MISO, GPIO_FUNC_SPI);
|
||||
gpio_set_function(PIN_CS, GPIO_FUNC_SIO);
|
||||
gpio_set_function(PIN_SCK, GPIO_FUNC_SPI);
|
||||
gpio_set_function(PIN_MOSI, GPIO_FUNC_SPI);
|
||||
|
||||
// Chip select is active-low, so we'll initialise it to a driven-high state
|
||||
gpio_set_dir(PIN_CS, GPIO_OUT);
|
||||
gpio_put(PIN_CS, 1);
|
||||
|
||||
// I2C Initialisation. Using it at 400Khz.
|
||||
i2c_init(I2C_PORT, 400*1000);
|
||||
|
||||
|
||||
gpio_set_function(I2C_SDA, GPIO_FUNC_I2C);
|
||||
gpio_set_function(I2C_SCL, GPIO_FUNC_I2C);
|
||||
gpio_pull_up(I2C_SDA);
|
||||
@@ -75,6 +59,12 @@ int main()
|
||||
|
||||
sleep_ms(1000);
|
||||
display.setRotation(1);
|
||||
display.clearDisplay();
|
||||
display.drawBitmap(0, 0, logo, 128, 64, SH110X_WHITE);
|
||||
display.display();
|
||||
|
||||
sleep_ms(1000);
|
||||
|
||||
display.clearDisplay();
|
||||
display.display();
|
||||
|
||||
@@ -82,25 +72,46 @@ int main()
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(SH110X_WHITE);
|
||||
display.setCursor(0,0);
|
||||
display.print("Hello from core 0!");
|
||||
display.print("Hello! core 1\n");
|
||||
display.display();
|
||||
|
||||
//multicore_launch_core1(core1_entry);
|
||||
|
||||
sleep_ms(1000);
|
||||
display.setTextSize(2);
|
||||
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.clearDisplay();
|
||||
display.setCursor(0,0);
|
||||
display.print(!gpio_get(BUTTON_A) ? "A\n" : "\n");
|
||||
display.print(!gpio_get(BUTTON_B) ? "B\n" : "\n");
|
||||
display.print(!gpio_get(BUTTON_C) ? "C\n" : "\n");
|
||||
display.display();
|
||||
sleep_ms(250);
|
||||
sleep_ms(100);
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
stdio_init_all();
|
||||
|
||||
// SPI initialisation. This example will use SPI at 1MHz.
|
||||
spi_init(SPI_PORT, 1000*1000);
|
||||
gpio_set_function(PIN_MISO, GPIO_FUNC_SPI);
|
||||
gpio_set_function(PIN_CS, GPIO_FUNC_SIO);
|
||||
gpio_set_function(PIN_SCK, GPIO_FUNC_SPI);
|
||||
gpio_set_function(PIN_MOSI, GPIO_FUNC_SPI);
|
||||
|
||||
// Chip select is active-low, so we'll initialise it to a driven-high state
|
||||
gpio_set_dir(PIN_CS, GPIO_OUT);
|
||||
gpio_put(PIN_CS, 1);
|
||||
|
||||
multicore_launch_core1(core1_entry);
|
||||
|
||||
// Timer example code - This example fires off the callback after 2000ms
|
||||
add_alarm_in_ms(2000, alarm_callback, NULL, false);
|
||||
|
||||
puts("Hello, world!");
|
||||
|
||||
return 0;
|
||||
while(true) {
|
||||
tight_loop_contents();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user