get build working with screen via pico-arduino-compat
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
#include <stdio.h>
|
||||
#include "Adafruit_GFX.h"
|
||||
#include "Adafruit_SH110x.h"
|
||||
#include "pico/stdlib.h"
|
||||
#include "pico/multicore.h"
|
||||
#include "hardware/spi.h"
|
||||
#include "hardware/i2c.h"
|
||||
#include "hardware/timer.h"
|
||||
@@ -14,18 +17,25 @@
|
||||
#define PIN_MOSI 19
|
||||
|
||||
// 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
|
||||
#define I2C_PORT i2c0
|
||||
#define I2C_SDA 8
|
||||
#define I2C_SCL 9
|
||||
#define I2C_PORT i2c1
|
||||
#define I2C_SDA 2
|
||||
#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) {
|
||||
// Put your timeout handler code in here
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void core1_entry()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
@@ -41,7 +51,6 @@ int main()
|
||||
// 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);
|
||||
@@ -50,6 +59,43 @@ int main()
|
||||
gpio_set_function(I2C_SCL, GPIO_FUNC_I2C);
|
||||
gpio_pull_up(I2C_SDA);
|
||||
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
|
||||
add_alarm_in_ms(2000, alarm_callback, NULL, false);
|
||||
|
||||
Reference in New Issue
Block a user