tinypico / tinypico-arduino Goto Github PK
View Code? Open in Web Editor NEWArduino libraries and example code for TinyPICO
License: MIT License
Arduino libraries and example code for TinyPICO
License: MIT License
I think I have found a problem in the TinyPICO setup. This may not be the correct place to report it but it seems better than nothing.
I'm using:
The Arduino IDE is set to:
Consider this sketch:
#include <Arduino.h>
#include <TinyPICO.h>
void check (const char * tag, uint8_t value, uint8_t expectedValue) {
if (value != expectedValue) {
Serial.printf(
"Symbol %s has value %d, expectedValue \n",
tag,
value,
expectedValue
);
}
}
void setup() {
Serial.begin(115200); while (!Serial); Serial.println();
/* these symbols should be available from pins_arduino.h */
// check("APA_POWER",APA_POWER,13);
// check("APA_DATA",APA_DATA,2);
// check("APA_CLK",APA_CLK,12);
/* these symbols should be available from TinyPICO.h */
check("DOTSTAR_PWR",DOTSTAR_PWR,13);
check("DOTSTAR_DATA",DOTSTAR_DATA,2);
check("DOTSTAR_CLK",DOTSTAR_CLK,12);
Serial.println("Complete");
}
void loop() { }
That compiles OK. But if I uncomment any of these three lines:
// check("APA_POWER",APA_POWER,13);
// check("APA_DATA",APA_DATA,2);
// check("APA_CLK",APA_CLK,12);
then the sketch won't compile, giving errors like:
sketch_tinyPicoPins:66:21: error: 'APA_CLK' was not declared in this scope
check("APA_CLK",APA_CLK,12);
^
The path:
~/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/variants/tinypico/pins_arduino.h
contains these lines:
static const uint8_t APA_POWER = 13;
static const uint8_t APA_DATA = 2;
static const uint8_t APA_CLK = 12;
so, all other things being equal, those symbols should be defined and available to the sketch.
Backtracking to:
~/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/boards.txt
finds this line:
tinypico.build.variant=pico32
and I think that means that, instead of the path to pins_arduino.h given above, the compiler is being directed to:
~/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/variants/pico32/pins_arduino.h
Comparing the two pins_arduino.h files produces:
$ diff ~/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/variants/pico32/pins_arduino.h ~/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/variants/tinypico/pins_arduino.h
55a56,59
> static const uint8_t APA_POWER = 13;
> static const uint8_t APA_DATA = 2;
> static const uint8_t APA_CLK = 12;
>
which explains the observed behaviour.
Hi,
I have an off situation here with your board running the sketch below.
Sketch
void setup() {
Serial.begin(115200);
Serial.print("I've been alive for ");
Serial.print(millis());
Serial.println("ms");
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
I'm building a project which deep-sleeps, counts pulses with the ULP, wakes up after a set amount, logs on to wifi, publishes the counter with mqtt and goes back to sleep.
The normal runtime on the devkit is around 300ms including wifi.
[33 ] ULP wakeup, saving pulse count
[33 ] Pulse count from ULP:4
[33 ] Wifi Setup - Starting
[68 ] Wifi Setup - Setting up WiFi Manager.....
[69 ] Wifi Setup - Setting up WiFi Manager.....done
[69 ] Got stored Credentials. Timeout 60s
[70 ] Wifi Setup - Done
[72 ] Wifi Setup - Connecting
[75 ] Connecting to CrappyIoTconnected! Local IP: 337512970
[259 ] Setting up MQTT Starting
[259 ] Attempting MQTT connection...
[292 ] MQTT connected!
[292 ] Leaving MQTT connect
[292 ] Setting up MQTT Complete
[296 ] Disconnecting from MQTT.
[297 ] MQTT disconnected.
[297 ] Finished. Going to sleep
[297 ] Entering deep sleep
You can see that being alive and "useless" for 1500ms is a battery killer in this way :)
Why would it be taking this long before it actually hit the setup?
C
According to datasheet, RGB LED has 32 levels of brightness unrelated to RGB value, so i've modified the code:
TinyPICO::TinyPICO()
{
...
brightness = 15;
...
}
void TinyPICO::DotStar_SetBrightness(uint8_t b)
{
if(b>31) b = 31;
brightness = b;
}
void TinyPICO::DotStar_Show(void)
{
if ( !isInit )
{
isInit = true;
swspi_init();
delay(10);
}
// Start-frame marker
for( int i=0; i<4; i++) swspi_out(0x00);
// Pixel start + brightness
swspi_out(0xE0 | brightness);
for( int i=0; i<3; i++) swspi_out(pixel[i]); // R,G,B @Full brightness (no scaling)
// // End frame marker
swspi_out(0xFF);
}
It works fine and RGB values aren't loosing precision. I don't know your original intention for manual brightness, so didn't want to make a pull request.
Another tweak i think is useful is to remove delay(1)
from the end of swspi_out
. LED works fine without delay but presence of it may be crucial for time sensitive tasks in main loop (like in my case).
Tried the DeepSleep example from the Arduino examples, stays at 20mA, with no decrease, sleep or not. I can do this on the ESP32 DOIT, without issue, sleep goes down to a couple mA.
Hoping update to Arduino tree from x.2 to x.3 resolves this:
The Play Shield example 'TinyPICO-Play-Shield-Features' shows this well:
With WiFi running a new Upload may take a RESET/repower/2nd upload to get the code uploaded to actually run
When running this sketch some alternate presses of button 4 will not show WiFi connect but long lines of '...' with no connect until another Button 4 press.
Please, describe, why not used FastLED library for APA102?
https://github.com/FastLED/FastLED/wiki/Overview#quickexample
Thanks!
If the TinyPICO helper is created and used immediately, the battery voltage reported is incorrect.
Rationale:
lastMeasuredVoltage isn't initialized in the constructor. Fix: in the constructor: lastMeasuredVoltage = 0.0f;
nextVoltage is set the current time, so if immediately after GetBatteryVoltage is called 'nextVoltage - millis() > 0' is false and the (currently uninitialized) lastMeasuredVoltage is returned without a new ADC read. Fix: in the constructor, change the nextVoltage initialization to: nextVoltage = millis() - 1; //do a '-1' to ensure I can get the battery voltage this msec.
Note that isToneInit isn't initialized in the constructor as well, even not related to this issue, I guess that initializing to false might be wise.
It returns TRUE when USB is not connected.
Probably because no one pulls up when no USB is connected?
tinypico-arduino/TinyPICO-Helper/src/TinyPICO.cpp
Lines 207 to 230 in 3b364e6
I'm not familiar enough yet with how the adc is configured and used and reused, but in debugging my program I've found that if I call the GetBatteryVoltage() function anywhere in my code... the ULP program I have that uses adc1 to wake on hall sensor readings fails to execute. I'm guessing because of the way this function uses the ADC that perhaps there needs to be some kind of release or reset on the adc? The ULP loading code looks like this:
esp_err_t err = ulp_load_binary(0, ulp_main_bin_start,
(ulp_main_bin_end - ulp_main_bin_start) /
sizeof(uint32_t));
ESP_ERROR_CHECK(err);
adc1_config_channel_atten(ADC1_CHANNEL_0, ADC_ATTEN_DB_0);
adc1_config_channel_atten(ADC1_CHANNEL_3, ADC_ATTEN_DB_0);
adc1_config_width(ADC_WIDTH_BIT_12);
adc1_ulp_enable();
esp_err_t ulp_run_err =
ulp_run((&ulp_entry - RTC_SLOW_MEM) / sizeof(uint32_t));
if (ulp_run_err != ESP_OK)
log_e("Failed to run ULP program.");
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.