Giter VIP home page Giter VIP logo

tinypico-helper's Introduction

TinyPICO Arduino Helper

This library adds some helper functions and useful pin assignments to make coding with TinyPICO & Arduino easier

We will be adding this library to the Arduino IDE library manager once we get closer to shipping the TinyPICOs.

TinyPICO Hardware Pin Assignments --------------------------------.. code-block:: c++

// APA102 Dotstar #define DOTSTAR_PWR 13 #define DOTSTAR_DATA 2 #define DOTSTAR_CLK 12

// Battery #define BAT_CHARGE 34 #define BAT_VOLTAGE 35

Helper functions

// Class constructor
TinyPICO();

// Get a *rough* estimate of the current battery voltage
// If the battery is not present, the charge IC will still report it's trying to charge at X voltage
// so it will still show a voltage.
float GetBatteryVoltage();

// Return the current charge state of the battery - we need to read the value multiple times
// to eliminate false negatives due to the charge IC not knowing the difference between no battery
// and a full battery not charging - This is why the charge LED flashes
bool IsChargingBattery();

// Power to the on-board Dotstar is controlled by a PNP transistor, so low is ON and high is OFF
// We also need to set the Dotstar clock and data pins to be inputs to prevent power leakage when power is off
// The reason we have power control for the Dotstar is that it has a quiescent current of around 1mA, so we
// need to be able to cut power to it to minimise power consumption during deep sleep or with general battery powered use
// to minimise unneeded battery drain
void DotStar_SetPower( bool state );

// On-board Dotstar control
void DotStar_Clear();
void DotStar_SetBrightness( uint8_t );
void DotStar_SetPixelColor( uint32_t c );
void DotStar_SetPixelColor( uint8_t r, uint8_t g, uint8_t b );
void DotStar_Show( void );
void DotStar_CycleColor();
void DotStar_CycleColor( unsigned long wait );
void DotStar_CycleColor();
void DotStar_CycleColor( unsigned long wait );

// Convert R,G,B values to uint32_t
uint32_t Color( uint8_t r, uint8_t g, uint8_t b );

Example Usage

tinypico-helper's People

Contributors

mcauser avatar unexpectedmaker avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tinypico-helper's Issues

RTCWDT_RTC_RESET issue

Hi!

I'm using a new Tiny PICO usb C board and after flashing in the example sketch:

#include <TinyPICO.h>

// Interval between internal temperature reads
unsigned long next_temp_read = 0;   // Next time step in milliseconds
uint8_t temp_read_interval = 1000;  // This is in milliseconds

// Initialise the TinyPICO library
TinyPICO tp = TinyPICO();

void setup()
{
    // Not used
}

void loop()
{
    // Cycle the DotStar colour every 25 milliseconds
    tp.DotStar_CycleColor(25);

    // You can set the DotStar colour directly using r,g,b values
    // tp.DotStar_SetPixelColor( 255, 128, 0 );

    // You can set the DotStar colour directly using a uint32_t value
    // tp.DotStar_SetPixelColor( 0xFFC900 );

    // You can clear the DotStar too
    // tp.DotStar_Clear();

    // To power down the DotStar for deep sleep you call this
    // tp.DotStar_SetPower( false );

}

I'm also using PlatformIO so this is my platformio.ini:

; 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

[env:esp32]
platform = espressif32
board = tinypico
framework = arduino
monitor_speed = 115200
build_flags = 
	'-DVERSION="0.0.1"'
	-D DEBUG=1
lib_deps = tinypico/TinyPICO Helper Library@^1.4.0

[platformio]
description = Surveyor for outside measurements

I'm getting the following error:

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 188777542, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:QIO, clock div:2
load:0x3fff0030,len:1344
load:0xcecccdfe,len:-822219570
1162 mmu set 00010000, pos 00010000
1162 mmu set 00020000, pos 00020000
1162 mmu set 00030000, pos 00030000
1162 mmu set 00040000, pos 00040000
1162 mmu set 00050000, pos 00050000
1162 mmu set 00060000, pos 00060000
1162 mmu set 00070000, pos 00070000
1162 mmu set 00080000, pos 00080000
1162 mmu set 00090000, pos 00090000
1162 mmu set 000a0000, pos 000a0000
1162 mmu set 000b0000, pos 000b0000
1162 mmu set 000c0000, pos 000c0000
1162 mmu set 000d0000, pos 000d0000
ets Jun  8 2016 00:22:57

I thought it was browning out but I already ruled out power supply issues (plugged in a battery, a reliable cable and even directly from a bench power supply).

All my pins are disconnected to sensors etc.

The initial program (that cycles the neo pixel) was running correctly before flashing the new program.

Any ideas on what might be going on?

Thanks!

IsChargingBattery boolean stays true even if USB is disconnected

Perhaps i'm not understanding this but IsChargingBattery does not seem to change to false (0) when I disconnect USB. At that point the TinyPICO (ESP32-PICO-D4) is completely running from battery. I'm using the VBAT and GND pin for the battery.

bool TinyPICO::IsChargingBattery()

To give you an idea. A snippet of the script below.

// Deep Sleep configuration
const unsigned long long int uS_TO_S_FACTOR            = 1000000;
int                          TIME_TO_SLEEP             = 900;    // In seconds
int                          DEEP_SLEEP_WHEN_CONNECTED = 60;     // In seconds

TinyPICO tp = TinyPICO();
bool IsChargingBattery = tp.IsChargingBattery();

// When connected to USB we'll change the DEEPSLEEP to X seconds  
if (IsChargingBattery == 1) {
  TIME_TO_SLEEP = DEEP_SLEEP_WHEN_CONNECTED;
} else {
  TIME_TO_SLEEP = TIME_TO_SLEEP;
}

esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
esp_deep_sleep_start(); 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.