Flashy lights tester
This commit is contained in:
parent
13483e5bcd
commit
856cc2e0d2
10 changed files with 353 additions and 0 deletions
BIN
Docs/sch_oled_0.49_v1.0.0.pdf
Normal file
BIN
Docs/sch_oled_0.49_v1.0.0.pdf
Normal file
Binary file not shown.
Binary file not shown.
11
TestJig/.gitignore
vendored
Normal file
11
TestJig/.gitignore
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
/.pio
|
||||
/.vscode/.browse.c_cpp.db*
|
||||
/.vscode/c_cpp_properties.json
|
||||
/.vscode/launch.json
|
||||
/.vscode/ipch
|
||||
/CMakeCache.txt
|
||||
/cmake_install.cmake
|
||||
/Makefile
|
||||
/CMakeFiles
|
||||
/cmake-build-debug
|
||||
/.idea
|
10
TestJig/.vscode/extensions.json
vendored
Normal file
10
TestJig/.vscode/extensions.json
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||
// for the documentation about the extensions.json format
|
||||
"recommendations": [
|
||||
"platformio.platformio-ide"
|
||||
],
|
||||
"unwantedRecommendations": [
|
||||
"ms-vscode.cpptools-extension-pack"
|
||||
]
|
||||
}
|
15
TestJig/CMakeLists.txt
Normal file
15
TestJig/CMakeLists.txt
Normal file
|
@ -0,0 +1,15 @@
|
|||
cmake_minimum_required(VERSION 3.29)
|
||||
project(TestJig)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
include_directories(
|
||||
.pio/libdeps/pico/Adafruit Neopixel
|
||||
.pio/libdeps/pico/Adafruit GFX Library
|
||||
.pio/libdeps/pico/Adafruit BusIO
|
||||
.pio/libdeps/pico/Adafruit SSD1306
|
||||
|
||||
.pio/packages/framework-arduinopico/cores/rp2040
|
||||
)
|
||||
|
||||
add_executable(TestJig
|
||||
src/main.cpp)
|
39
TestJig/include/README
Normal file
39
TestJig/include/README
Normal file
|
@ -0,0 +1,39 @@
|
|||
|
||||
This directory is intended for project header files.
|
||||
|
||||
A header file is a file containing C declarations and macro definitions
|
||||
to be shared between several project source files. You request the use of a
|
||||
header file in your project source file (C, C++, etc) located in `src` folder
|
||||
by including it, with the C preprocessing directive `#include'.
|
||||
|
||||
```src/main.c
|
||||
|
||||
#include "header.h"
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Including a header file produces the same results as copying the header file
|
||||
into each source file that needs it. Such copying would be time-consuming
|
||||
and error-prone. With a header file, the related declarations appear
|
||||
in only one place. If they need to be changed, they can be changed in one
|
||||
place, and programs that include the header file will automatically use the
|
||||
new version when next recompiled. The header file eliminates the labor of
|
||||
finding and changing all the copies as well as the risk that a failure to
|
||||
find one copy will result in inconsistencies within a program.
|
||||
|
||||
In C, the usual convention is to give header files names that end with `.h'.
|
||||
It is most portable to use only letters, digits, dashes, and underscores in
|
||||
header file names, and at most one dot.
|
||||
|
||||
Read more about using header files in official GCC documentation:
|
||||
|
||||
* Include Syntax
|
||||
* Include Operation
|
||||
* Once-Only Headers
|
||||
* Computed Includes
|
||||
|
||||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
46
TestJig/lib/README
Normal file
46
TestJig/lib/README
Normal file
|
@ -0,0 +1,46 @@
|
|||
|
||||
This directory is intended for project specific (private) libraries.
|
||||
PlatformIO will compile them to static libraries and link into executable file.
|
||||
|
||||
The source code of each library should be placed in an own separate directory
|
||||
("lib/your_library_name/[here are source files]").
|
||||
|
||||
For example, see a structure of the following two libraries `Foo` and `Bar`:
|
||||
|
||||
|--lib
|
||||
| |
|
||||
| |--Bar
|
||||
| | |--docs
|
||||
| | |--examples
|
||||
| | |--src
|
||||
| | |- Bar.c
|
||||
| | |- Bar.h
|
||||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
||||
| |
|
||||
| |--Foo
|
||||
| | |- Foo.c
|
||||
| | |- Foo.h
|
||||
| |
|
||||
| |- README --> THIS FILE
|
||||
|
|
||||
|- platformio.ini
|
||||
|--src
|
||||
|- main.c
|
||||
|
||||
and a contents of `src/main.c`:
|
||||
```
|
||||
#include <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
PlatformIO Library Dependency Finder will find automatically dependent
|
||||
libraries scanning project source files.
|
||||
|
||||
More information about PlatformIO Library Dependency Finder
|
||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
50
TestJig/platformio.ini
Normal file
50
TestJig/platformio.ini
Normal file
|
@ -0,0 +1,50 @@
|
|||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter
|
||||
; Upload options: custom upload port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
; Advanced options: extra scripting
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
[platformio]
|
||||
default_envs = pico
|
||||
platforms_dir = .pio/platforms
|
||||
libdeps_dir = .pio/libdeps
|
||||
cache_dir = .pio/cache
|
||||
build_dir = .pio/build
|
||||
build_cache_dir = .pio/build_cache
|
||||
packages_dir = .pio/packages
|
||||
|
||||
[common]
|
||||
build_flags =
|
||||
-std=c++17
|
||||
build_unflags =
|
||||
-std=gnu++11
|
||||
lib_deps =
|
||||
adafruit/Adafruit NeoPixel@^1.12.3
|
||||
olikraus/U8g2@^2.35.30
|
||||
|
||||
[env:pico]
|
||||
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
|
||||
board = vccgnd_yd_rp2040
|
||||
framework = arduino
|
||||
board_build.core = earlephilhower
|
||||
board_build.mcu = rp2040
|
||||
board_build.f_cpu = 133000000L
|
||||
|
||||
# Used for overloading linker script to do fucky things
|
||||
#board_build.ldscript = memmap.ld
|
||||
|
||||
# Used for using debug probe
|
||||
#debug_tool = cmsis-dap
|
||||
#upload_protocol = cmsis-dap
|
||||
#debug_init_break =
|
||||
|
||||
monitor_raw = yes
|
||||
build_flags =
|
||||
${common.build_flags}
|
||||
build_unflags =
|
||||
${common.build_unflags}
|
||||
lib_deps =
|
||||
${common.lib_deps}
|
171
TestJig/src/main.cpp
Normal file
171
TestJig/src/main.cpp
Normal file
|
@ -0,0 +1,171 @@
|
|||
#include <cstdint>
|
||||
#include <Arduino.h>
|
||||
#include <FreeRTOS.h>
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_NeoPixel.h>
|
||||
#include <U8x8lib.h>
|
||||
|
||||
#define PIXEL_COUNT 124
|
||||
#define PIXEL_PIN 16
|
||||
#define PIXEL_BRIGHTNESS 10
|
||||
//#define SCREEN_RESET_PIN 22
|
||||
#define SCREEN_RESET_PIN U8X8_PIN_NONE
|
||||
|
||||
U8X8_SSD1306_72X40_ER_HW_I2C u8x8(SCREEN_RESET_PIN);
|
||||
|
||||
Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800);
|
||||
|
||||
int count = 0;
|
||||
|
||||
void rainbow(int wait) {
|
||||
for(long firstPixelHue = 0; firstPixelHue < 5*65536; firstPixelHue += 256) {
|
||||
// apply rainbow to the first 64 pixels
|
||||
for(int i=0; i<=63; i++) {
|
||||
int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels());
|
||||
strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue)));
|
||||
}
|
||||
|
||||
// Blank everything over pixel 64
|
||||
//for(int j=65; j<=124; j++) strip.setPixelColor(j-1, strip.Color(0,0,0));
|
||||
// 65->72 to mirror 4
|
||||
for(int j=65; j<=72; j++) strip.setPixelColor(j-1, strip.getPixelColor(4-1));
|
||||
// 73->79 to mirror 12
|
||||
for(int j=73; j<=79; j++) strip.setPixelColor(j-1, strip.getPixelColor(12-1));
|
||||
// 80->86 to mirror 20
|
||||
for(int j=80; j<=86; j++) strip.setPixelColor(j-1, strip.getPixelColor(20-1));
|
||||
// 87->94 to mirror 28
|
||||
for(int j=87; j<=94; j++) strip.setPixelColor(j-1, strip.getPixelColor(28-1));
|
||||
// 95->102 to mirror 36
|
||||
for(int j=95; j<=102; j++) strip.setPixelColor(j-1, strip.getPixelColor(36-1));
|
||||
// 103->109 to mirror 44
|
||||
for(int j=103; j<=109; j++) strip.setPixelColor(j-1, strip.getPixelColor(44-1));
|
||||
// 110->116 to mirror 52
|
||||
for(int j=110; j<=116; j++) strip.setPixelColor(j-1, strip.getPixelColor(52-1));
|
||||
// 117->124 to mirror 60
|
||||
for(int j=117; j<=124; j++) strip.setPixelColor(j-1, strip.getPixelColor(60-1));
|
||||
|
||||
// Show and wait
|
||||
strip.show();
|
||||
delay(wait);
|
||||
}
|
||||
|
||||
}
|
||||
void all(uint8_t red, uint8_t green, uint8_t blue){
|
||||
for(int i=0; i<strip.numPixels(); i++) {
|
||||
strip.setPixelColor(i, strip.Color(red,green,blue));
|
||||
}
|
||||
strip.show();
|
||||
}
|
||||
void i2cScan(){
|
||||
byte error, address;
|
||||
int nDevices;
|
||||
|
||||
Serial.println("i2c Scan: Scanning bus for devices...");
|
||||
|
||||
nDevices = 0;
|
||||
for(address = 1; address < 127; address++ )
|
||||
{
|
||||
// The i2c_scanner uses the return value of
|
||||
// the Write.endTransmisstion to see if
|
||||
// a device did acknowledge to the address.
|
||||
Wire.beginTransmission(address);
|
||||
error = Wire.endTransmission();
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
Serial.print("i2c Scan: I2C device found at address 0x");
|
||||
if (address<16)
|
||||
Serial.print("0");
|
||||
Serial.print(address,HEX);
|
||||
Serial.println(" !");
|
||||
|
||||
nDevices++;
|
||||
}
|
||||
else if (error==4)
|
||||
{
|
||||
Serial.print("i2c Scan: Unknown error at address 0x");
|
||||
if (address<16)
|
||||
Serial.print("0");
|
||||
Serial.println(address,HEX);
|
||||
}
|
||||
}
|
||||
if (nDevices == 0)
|
||||
Serial.println("i2c Scan: No I2C devices found");
|
||||
else
|
||||
Serial.println("i2c Scan: Complete");
|
||||
|
||||
}
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
delay(2000);
|
||||
|
||||
// Delay startup
|
||||
Serial.println("Early startup");
|
||||
|
||||
// Initialise i2c
|
||||
Wire.begin();
|
||||
// Initialise Neopixels
|
||||
strip.begin();
|
||||
Serial.print("Setting Neopixel brightness to ");
|
||||
Serial.print(PIXEL_BRIGHTNESS);
|
||||
Serial.println("%");
|
||||
strip.setBrightness(PIXEL_BRIGHTNESS);
|
||||
all(10,10,10);
|
||||
strip.show();
|
||||
|
||||
// Run i2cScan
|
||||
i2cScan();
|
||||
|
||||
// Initialise oled display using internal VCC pump
|
||||
Serial.print("Configuring display... ");
|
||||
|
||||
u8x8.begin();
|
||||
u8x8.setPowerSave(false); // Power save keeps the controller alive but turns off the pixels
|
||||
u8x8.setFlipMode(true);
|
||||
|
||||
u8x8.setFont(u8x8_font_5x7_f);
|
||||
u8x8.drawString(0,0,"123456789");
|
||||
u8x8.drawString(0,1,"abcdefghi");
|
||||
u8x8.drawString(0,2,"ABCDEFGHI");
|
||||
u8x8.drawString(0,3,"2020-12-01");
|
||||
u8x8.drawString(0,4,"12:00:00");
|
||||
u8x8.drawString(0,5,"---------");
|
||||
u8x8.drawString(0,6,"*********");
|
||||
delay(300);
|
||||
u8x8.fillDisplay();
|
||||
delay(300);
|
||||
u8x8.clearDisplay();
|
||||
Serial.println("Complete!");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
count++;
|
||||
Serial.print("Cycle ");
|
||||
Serial.print(count);
|
||||
Serial.print(".\n");
|
||||
|
||||
Serial.println("Red...");
|
||||
all(255,0,0);
|
||||
u8x8.clearDisplay();
|
||||
u8x8.drawString(0,2,"Red!");
|
||||
delay(500);
|
||||
|
||||
Serial.println("Green...");
|
||||
all(0,255,0);
|
||||
u8x8.clearDisplay();
|
||||
u8x8.drawString(0,1,"Green!");
|
||||
delay(500);
|
||||
|
||||
Serial.println("Blue...");
|
||||
all(0,0,255);
|
||||
u8x8.clearDisplay();
|
||||
u8x8.drawString(0,4,"Blue!");
|
||||
delay(500);
|
||||
|
||||
|
||||
Serial.println("Rainbow!");
|
||||
u8x8.clearDisplay();
|
||||
u8x8.drawString(0,3,"Rainbow!");
|
||||
rainbow(1);
|
||||
|
||||
}
|
11
TestJig/test/README
Normal file
11
TestJig/test/README
Normal file
|
@ -0,0 +1,11 @@
|
|||
|
||||
This directory is intended for PlatformIO Test Runner and project tests.
|
||||
|
||||
Unit Testing is a software testing method by which individual units of
|
||||
source code, sets of one or more MCU program modules together with associated
|
||||
control data, usage procedures, and operating procedures, are tested to
|
||||
determine whether they are fit for use. Unit testing finds problems early
|
||||
in the development cycle.
|
||||
|
||||
More information about PlatformIO Unit Testing:
|
||||
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html
|
Loading…
Reference in a new issue