single repo
This commit is contained in:
19
pico-ssd1306/examples/draw_line/CMakeLists.txt
Normal file
19
pico-ssd1306/examples/draw_line/CMakeLists.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
|
||||
include(pico_sdk_import.cmake)
|
||||
|
||||
project(line_example)
|
||||
|
||||
pico_sdk_init()
|
||||
|
||||
add_subdirectory(pico-ssd1306)
|
||||
|
||||
add_executable(line_example
|
||||
main.cpp)
|
||||
|
||||
target_link_libraries(line_example
|
||||
hardware_i2c
|
||||
pico_ssd1306)
|
||||
|
||||
|
||||
pico_add_extra_outputs(line_example)
|
||||
31
pico-ssd1306/examples/draw_line/main.cpp
Normal file
31
pico-ssd1306/examples/draw_line/main.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "pico/stdlib.h"
|
||||
#include "pico-ssd1306/ssd1306.h"
|
||||
#include "pico-ssd1306/shapeRenderer/ShapeRenderer.h"
|
||||
#include "hardware/i2c.h"
|
||||
|
||||
// Use the namespace for convenience
|
||||
using namespace pico_ssd1306;
|
||||
|
||||
int main(){
|
||||
// Init i2c0 controller
|
||||
i2c_init(i2c0, 1000000);
|
||||
// Set up pins 12 and 13
|
||||
gpio_set_function(12, GPIO_FUNC_I2C);
|
||||
gpio_set_function(13, GPIO_FUNC_I2C);
|
||||
gpio_pull_up(12);
|
||||
gpio_pull_up(13);
|
||||
|
||||
// If you don't do anything before initializing a display pi pico is too fast and starts sending
|
||||
// commands before the screen controller had time to set itself up, so we add an artificial delay for
|
||||
// ssd1306 to set itself up
|
||||
sleep_ms(250);
|
||||
|
||||
// Create a new display object at address 0x3D and size of 128x64
|
||||
SSD1306 display = SSD1306(i2c0, 0x3D, Size::W128xH64);
|
||||
|
||||
// Draw a line on display from 0, 0 to 127, 63
|
||||
drawLine(&display, 0, 0 ,127, 63);
|
||||
|
||||
// Send buffer to the display
|
||||
display.sendBuffer();
|
||||
}
|
||||
BIN
pico-ssd1306/examples/draw_line/output.jpg
Normal file
BIN
pico-ssd1306/examples/draw_line/output.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 895 KiB |
3
pico-ssd1306/examples/draw_line/readme.md
Normal file
3
pico-ssd1306/examples/draw_line/readme.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# This examples produces such a result
|
||||
|
||||

|
||||
Reference in New Issue
Block a user