4 Commits

Author SHA1 Message Date
Charles
048167311d Change according new NeoPixelbus library 2016-05-09 16:08:12 +02:00
Charles
976095f3ef Added bytes alignment calculation on ESP8266 2016-05-09 16:07:38 +02:00
Charles
61d36940d9 v1.0.2 2016-05-09 16:06:52 +02:00
Charles
8069dde82f Reworked http;begin call to conform new ESP lib 2016-05-09 15:49:08 +02:00
7 changed files with 87 additions and 24 deletions

View File

@@ -74,14 +74,22 @@ extern "C" {
#define BLINK_LED_MS 50 // 50 ms blink
#define RGB_LED_PIN 14
#define RED_LED_PIN 12
// value for RGB color
#define COLOR_RED rgb_brightness, 0, 0
#define COLOR_ORANGE rgb_brightness, rgb_brightness>>1, 0
#define COLOR_YELLOW rgb_brightness, rgb_brightness, 0
#define COLOR_GREEN 0, rgb_brightness, 0
#define COLOR_CYAN 0, rgb_brightness, rgb_brightness
#define COLOR_BLUE 0, 0, rgb_brightness
#define COLOR_MAGENTA rgb_brightness, 0, rgb_brightness
// value for HSL color
// see http://www.workwithcolor.com/blue-color-hue-range-01.htm
#define COLOR_RED 0
#define COLOR_ORANGE 30
#define COLOR_ORANGE_YELLOW 45
#define COLOR_YELLOW 60
#define COLOR_YELLOW_GREEN 90
#define COLOR_GREEN 120
#define COLOR_GREEN_CYAN 165
#define COLOR_CYAN 180
#define COLOR_CYAN_BLUE 210
#define COLOR_BLUE 240
#define COLOR_BLUE_MAGENTA 275
#define COLOR_MAGENTA 300
#define COLOR_PINK 350
// GPIO 1 TX on board blue led
#ifdef BLU_LED_PIN
@@ -96,9 +104,10 @@ extern "C" {
#define LedRedOFF() {digitalWrite(RED_LED_PIN, 0);}
// Light off the RGB LED
#define LedRGBOFF() { rgb_led.SetPixelColor(0,0,0,0); rgb_led.Show(); }
#define LedRGBON(x) { rgb_led.SetPixelColor(0,x); rgb_led.Show(); }
#ifndef RGB_LED_PIN
#define LedRGBOFF() {}
#define LedRGBON(x) {}
#endif
// sysinfo informations
typedef struct
{
@@ -110,7 +119,6 @@ typedef struct
extern ESP8266WebServer server;
extern WiFiUDP OTA;
extern TInfo tinfo;
extern NeoPixelBus rgb_led ;
extern uint8_t rgb_brightness;
extern unsigned long seconds;
extern _sysinfo sysinfo;

View File

@@ -46,11 +46,15 @@ bool ota_blink;
// Teleinfo
TInfo tinfo;
// RGB Loed
NeoPixelBus rgb_led = NeoPixelBus(1, RGB_LED_PIN, NEO_RGB | NEO_KHZ800);
// RGB Led
#ifdef RGB_LED_PIN
//NeoPixelBus rgb_led = NeoPixelBus(1, RGB_LED_PIN, NEO_RGB | NEO_KHZ800);
NeoPixelBus<NeoGrbFeature, NeoEsp8266BitBang800KbpsMethod> rgb_led(1, RGB_LED_PIN);
#endif
// define whole brigtness level for RGBLED
uint8_t rgb_brightness = 127;
// define whole brigtness level for RGBLED (50%)
uint8_t rgb_brightness = 50;
// LED Blink timers
Ticker rgb_ticker;
Ticker blu_ticker;
@@ -143,6 +147,51 @@ void LedOff(int led)
LedRGBOFF();
}
// Light off the RGB LED
#ifdef RGB_LED_PIN
/* ======================================================================
Function: LedRGBON
Purpose : Light RGB Led with HSB value
Input : Hue (0..255)
Saturation (0..255)
Brightness (0..255)
Output : -
Comments:
====================================================================== */
void LedRGBON (uint16_t hue)
{
if (config.config & CFG_RGB_LED) {
// Convert to neoPixel API values
// H (is color from 0..360) should be between 0.0 and 1.0
// L (is brightness from 0..100) should be between 0.0 and 0.5
RgbColor target = HslColor( hue / 360.0f, 1.0f, rgb_brightness * 0.005f );
// Set RGB Led
rgb_led.SetPixelColor(0, target);
rgb_led.Show();
}
}
/* ======================================================================
Function: LedRGBOFF
Purpose : light off the RGN LED
Input : -
Output : -
Comments: -
====================================================================== */
//void LedOff(int led)
void LedRGBOFF(void)
{
if (config.config & CFG_RGB_LED) {
rgb_led.SetPixelColor(0,RgbColor(0));
rgb_led.Show();
}
}
#endif
/* ======================================================================
Function: ADPSCallback
Purpose : called by library when we detected a ADPS on any phased

View File

@@ -39,7 +39,7 @@ boolean httpPost(char * host, uint16_t port, char * url)
unsigned long start = millis();
// configure traged server and url
http.begin(host, port, url, port==443 ? true : false);
http.begin(host, port, url);
//http.begin("http://emoncms.org/input/post.json?node=20&apikey=2f13e4608d411d20354485f72747de7b&json={PAPP:100}");
//http.begin("emoncms.org", 80, "/input/post.json?node=20&apikey=2f13e4608d411d20354485f72747de7b&json={}"); //HTTP

View File

@@ -7,7 +7,7 @@
"type": "git",
"url": "https://github.com/hallard/LibTeleinfo.git"
},
"version": "1.0.1",
"version": "1.0.2",
"authors":
{
"name": "Charles-Henri Hallard",

View File

@@ -1,5 +1,5 @@
name=LibTeleinfo
version=1.0.1
version=1.0.2
author=Charles-Henri Hallard <hallard.me>
maintainer=Charles-Henri Hallard <community.hallard.me>
sentence=Teleinfo French power meter reader and decoding

View File

@@ -249,10 +249,10 @@ ValueList * TInfo::valueAdd(char * name, char * value, uint8_t checksum, uint8_t
// + Value + '\0'
size_t size ;
#ifdef ESP8266
lgname = xPortWantedSizeAlign(lgname+1); // Align name buffer
lgvalue = xPortWantedSizeAlign(lgvalue+1); // Align value buffer
lgname = ESP8266_allocAlign(lgname+1); // Align name buffer
lgvalue = ESP8266_allocAlign(lgvalue+1); // Align value buffer
// Align the whole structure
size = xPortWantedSizeAlign( sizeof(ValueList) + lgname + lgvalue ) ;
size = ESP8266_allocAlign( sizeof(ValueList) + lgname + lgvalue ) ;
#else
size = sizeof(ValueList) + lgname + 1 + lgvalue + 1 ;
#endif

View File

@@ -38,10 +38,10 @@
// Using ESP8266 ?
#ifdef ESP8266
//#include "stdlib_noniso.h"
#include <ESP8266WiFi.h>
#endif
// Define this if you want library to be verbose
//#define TI_DEBUG
@@ -67,6 +67,12 @@
#define TI_Debugflush
#endif
#ifdef ESP8266
// For 4 bytes Aligment boundaries
#define ESP8266_allocAlign(size) ((size + 3) & ~((size_t) 3))
#endif
#pragma pack(push) // push current alignment to stack
#pragma pack(1) // set alignment to 1 byte boundary