Open dragondaud opened 5 years ago
Very nice.
I also tested something for information. It's about openweather and got weather condition related to my country language (last line of display) but for this you need 2 things:
lang=FR
`String URL = PSTR("http://api.openweathermap.org/data/2.5/weather?zip=")
description
instead of main
String description = weather["description"];
now it displays nuageux
instead of cloudy
About Celsius conversion, I think colors should be adjusted to "classic" °C threeshold values such as
if (temperature < 0) display.setTextColor(myCYAN);
else if (temperature < 10) display.setTextColor(myBLUE);
else if (temperature < 15) display.setTextColor(myMAGENTA);
else if (temperature < 25) display.setTextColor(myGREEN);
else if (temperature >= 25) display.setTextColor(myYELLOW);
else if (temperature >= 30) display.setTextColor(myORANGE);
else if (temperature >= 35) display.setTextColor(myRED);
I let you change the colors of course, what's important are the digit such as 0 10 15 25 30 and 35 and I think we could even add 20°C threshold because it's the confort temperature on a house
I pushed a new version, with language support and made some changes to the top line color selection. Eventually there will be a drop down for language, but for now it's just another field in the config.json file. Thanks for the feedback!
I ad originally used the "short" description because some of the english texts are very long, but enabling localization seems like a good idea, and its only available on the long description. After looking through them again, it seems to be mostly excessive use of "intensity" that causes the long ones. So, I'm removing the word from output. Today at my locale we were having 'light intensity drizzle'. which becomes simply 'light drizzle' and it seems the FR version doesn't have extra unnecessary words.
Hey, just found this 👍 One thing I was about to (newbie!) try and do was embed DST - currently, my running version is an hour out as we are on daylight savings. I've used this library before... https://github.com/neptune2/simpleDSTadjust, is this something to add? :)
myClock automatically adjusts for DST, if you location is correct. By default it will use geoIP to determine your timezone, and location for weather info. If that is wrong, then you can manually set your location on the webpage of the clock.
Perfect, thanks... if only I could get it to compile :( See the issue I opened! Appreciate your help
Working now,
Dont know if it was just me, but to get code to work in Tools, I had to set Flash as :
Once operating, with String Location as empty then If I left as "/forecast?q=" then got an Json parse error
Some issues with the openweather API Call.
By default, with String location; // Blank
This is the serial output
getIPlocation: Telstra Internet, New South Wales, AU, Australia/Sydney 17:58:11.879 -> setup: Ryde, AU, Australia/Sydney, true, 255, 0 setNTP: configure NTP .... OK 17:58:15.684 -> setNTP: next timezone check @ Tue Oct 16 02:00:00 2018 17:58 http://api.openweathermap.org/data/2.5/weather?zip=Ryde, AU&units=metric&lang=en&appid=xxx getWeather: GET failed: 404 17:58 0 255
If I change the api string to /weather?q= then I get this
getIPlocation: Telstra Internet, New South Wales, AU, Australia/Sydney 18:00:34.967 -> setup: 2112, Australia/Sydney, true, 255, 0 setNTP: configure NTP ..... OK 18:00:37.767 -> setNTP: next timezone check @ Tue Oct 16 02:00:00 2018 18:00 http://api.openweathermap.org/data/2.5/weather?q=2112&units=metric&lang=en&appid=xxx 9F, 61%, 2 E (130), clear sky (800)
The wrong weather, clearly my ZIP (Postcode) of 2112 does not work.
Checking here - https://openweathermap.org/current if I force my location to : String location = "Ryde, AU";
Then it works :-
18:11:06.472 -> readSPIFFS: mounted getIPlocation: Telstra Internet, New South Wales, AU, Australia/Sydney 18:11:12.670 -> setup: Ryde, AU, Australia/Sydney, true, 255, 0 18:11:12.670 -> setNTP: configure NTP ..... OK 18:11:14.671 -> setNTP: next timezone check @ Tue Oct 16 02:00:00 2018 18:11 http://api.openweathermap.org/data/2.5/weather?q=Ryde, AU&units=metric&lang=en&appid=xxx 21F, 68%, 8 NE (50), shower rain (521) 18:11 0 255
So there is some inconsistency here in the GetIPlocation, seems to return Ryde, AU sometimes and 2112 other times.
A space is not valid in a URL, unless encoded as %20, so to use the ?q=City,CC lookup format, make sure there is no space after the comma. As for postal code, I just noticed in the API doc that the default is USA and to use another country's postal code you must specify it like:
api.openweathermap.org/data/2.5/weather?zip={zip code},{country code}
So I will look at making an update to support that.
Enhancement request :) Would love to see Day, Date displayed. With limited real estate perhaps the weather could alternate with the date?
The local Country Code, as obtained from ip-api.com, is now included with weather lookup request. Personally, I wouldn't want my clock's display so busy with alternating the date. Right now I'm working towards a 1.0 release, with emphasis on usability and stability. After that, new features might be added. Thanks for your input.
Dave - just wondering if this is a "bug" / "undocumented feature" :) the pixels on the bottom line? Seem random?
The code that clears the bottom was fixed a few commits back. Previously, with short descriptions, the very bottom line was never used and I didn't notice the error, but it should be fixed in the current code. The red number that appears occasionally is the status code returned if the weather lookup fails.
I'm having some trouble with french char on openweather because of utf8 format
Adding this to weather.ino should to the trick (taken from arduino) and checked with TOMTHUMB_USE_EXTENDED and font, should work.
byte utf8ascii(byte ascii) {
static byte c1; // Last character buffer
if ( ascii<128 ) // Standard ASCII-set 0..0x7F handling
{ c1=0;
return( ascii );
}
// get previous input
byte last = c1; // get last char
c1=ascii; // remember actual character
switch (last) // conversion depending on first UTF8-character
{ case 0xC2: return (ascii); break;
case 0xC3: return (ascii | 0xC0); break;
case 0x82: if(ascii==0xAC) return(0x80); // special case Euro-symbol
}
return (0); // otherwise: return zero, if character has to be ignored
}
String utf8ascii(String s)
{
String r="";
char c;
for (int i=0; i<s.length(); i++)
{
c = utf8ascii(s.charAt(i));
if (c!=0) r+=c;
}
return r;
}
void utf8ascii(char* s)
{
int k=0;
char c;
for (int i=0; i<strlen(s); i++)
{
c = utf8ascii(s[i]);
if (c!=0)
s[k++]=c;
}
s[k]=0;
}
then code to get weather description should be something like that.
String desc = weather["description"];
String description = utf8ascii(desc);
can't test since bug in latest http parsing from ESP8266 repo, I'll do that ASAP
Just to let you know that the PCB Shield V1.6 just released now support Wemos ESP32 Mini. This should solve all of our heap problem and add new features.
Not sure if it will work "as is" may be code need some adaptation.
Repo and PCB's.io link updated with some pictures. https://github.com/hallard/WeMos-Matrix-Shield
I'm sure it would require tweaking, but not much. I do have a couple ESP32s around here I picked up for other projects, so I might test it out and add a few #ifdef as needed. :)
Great, but as far as I remember WebServer implementation is different, last year I tried to port old ESP8266 project to ESP32 and it was a pain. But the asyncWEBServer version works on ESP8266 and ESP32 ;-)
BTW, the french char are now working fine, thanks for fixing this.
I'll update the issue #7 for removing long terms
Added support for ESP32 today. Compiles and runs, though I haven't mapped the pins or verified them on matrix shield v1.6.
ESP32 works on V1.6 boards (but there are some flickering), needs some adjustments as follow for ESP32 MH-Et Live :
in file pxMatrix.h
from https://github.com/2dom/PxMatrix
change SPI pin definitions. They are hard coded in the code for ESP32 to 14,13,12,4 change to 18,23,19,5
// HW SPI PINS
//#define SPI_BUS_CLK 14
//#define SPI_BUS_MOSI 13
//#define SPI_BUS_MISO 12
//#define SPI_BUS_SS 4
#define SPI_BUS_CLK 18
#define SPI_BUS_MOSI 23
#define SPI_BUS_MISO 19
#define SPI_BUS_SS 5
in file display.h
of the project, change pin definition for ESP32
#if defined(ESP8266)
#define P_LAT 16
#define P_A 5
#define P_B 4
#define P_C 15
#define P_D 12
#define P_E 0 // not needed on 64x32
#define P_OE 2
#else
#define P_LAT 26
#define P_A 22
#define P_B 21
#define P_C 5
#define P_D 19
#define P_E 17 // not needed on 64x32
#define P_OE 16
#endif
And the board with ESP32
PCB Shield repo updated https://github.com/hallard/WeMos-Matrix-Shield
Ok, solved flickering on ESP32 by changing on display_updater()
in display.h
as follow
#if defined (ESP8266)
// ISR for display refresh
void display_updater()
{
display.display(70);
}
#elif defined (ESP32)
portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;
void IRAM_ATTR display_updater()
{
portENTER_CRITICAL_ISR(&timerMux);
display.display(15);
portEXIT_CRITICAL_ISR(&timerMux);
}
#endif
BTW, where is the light meter on web interface I can't see it anymore ?
Added hallard's display updater change, and re-added the light meter to web page.
I had to rebuild my MacBook Pro (thanks Teamviewer!), which meant reinstalling the Arduino app and such. When I run the build script, it's not extracting the path to esptool
. While I'm well versed in bash scripts, C programmed, and world of other things, the Arduino app is not one of them. How does esptool
get into the preferences? Here's the script output (I added a -t
option to build for the Sparkfun ESP32 Thing, added -S
that uses whatever -t
set SER
to, and overwrote the boardsmanager
and boardsver
variables).
Any ideas how runtime.tools.esptool.path
gets set?
$ ./build.sh -t -s /dev/cu.usbserial-DN02SFL6
+ APP=myClock
+ SRC=myClock.ino
+ BIN=myClock.ino.bin
++ which rm
+ RM=/bin/rm
++ which python
+ PYTHON=/usr/bin/python
+ BOLD='\033[1;34m'
+ NC='\033[0m'
+ boardsmanager=https://dl.espressif.com/dl/package_esp32_index.json
+ boardver=esp32:esp32:1.0.2
+ board=espressif:esp32:esp32thing:PartitionScheme=min_spiffs,UploadSpeed=921600,FlashFreq=80
+ SER=/dev/cu.usbserial-DN02SFL6
+ [[ darwin18 == \d\a\r\w\i\n* ]]
+ arduino=/Applications/Arduino.app/Contents/MacOS/Arduino
+ buildpath=/Users/jcw/.build
+ '[' -z /Applications/Arduino.app/Contents/MacOS/Arduino ']'
++ /Applications/Arduino.app/Contents/MacOS/Arduino --get-pref sketchbook.path
+ SKETCHBOOK=/Users/jcw/Documents/Arduino
+ getopts :ltvf:s:hcwuoS opt
+ case $opt in
++ /Applications/Arduino.app/Contents/MacOS/Arduino --get-pref runtime.tools.esptool.path
+ esptool=/esptool
+ echo 'Uploading to /dev/cu.usbserial-DN02SFL6 with /esptool.'
Uploading to /dev/cu.usbserial-DN02SFL6 with /esptool.
+ getopts :ltvf:s:hcwuoS opt
+ echo -e '\033[1;34mBuilding myClock\033[0m in /Users/jcw/.build...'
Building myClock in /Users/jcw/.build...
+ /Applications/Arduino.app/Contents/MacOS/Arduino --pref build.path=/Users/jcw/.build --board espressif:esp32:esp32thing:PartitionScheme=min_spiffs,UploadSpeed=921600,FlashFreq=80 --save-prefs --verify myClock.ino
Loading configuration...
Initializing packages...
Preparing boards...
Verifying...
Sketch uses 948054 bytes (48%) of program storage space. Maximum is 1966080 bytes.
Global variables use 68424 bytes (20%) of dynamic memory, leaving 259256 bytes for local variables. Maximum is 327680 bytes.
+ ret=0
+ '[' 0 -eq 0 ']'
+ '[' -f '' ']'
+ '[' -f /esptool ']'
+ echo 'build complete'
build complete
$
It should be set by the core, though I did only minimal testing with ESP32 or MacOS. Apparently the option is called runtime.tools.esptool_py.path with ESP32... :/
Just to let you know that the PCB Shield V1.6 just released now support Wemos ESP32 Mini. This should solve all of our heap problem and add new features.
Not sure if it will work "as is" may be code need some adaptation.
Repo and PCB's.io link updated with some pictures. https://github.com/hallard/WeMos-Matrix-Shield
since there seems to be a problem with PCBs.io you can order the v1.6 PCBs here: https://aisler.net/p/DRGKVMVA or upload them yourself for any other version. I Orderd already 3 times there, different pcbs, and they always delivered very fast 5-6 days
Intending to push V1.0, Soon, after any bugs are fixed, and the following features implemented.
Support for Celsius temperature display (both local/indoor and openweather)Support for localization of weather descriptionsRework each config option into its own control on webpageUpdate directly from github binary release, manually or automatically
Verify/fix functionality of GeoIP automatic location, outside USAAdd country code to ?zip= weather lookup, outside USASupport ESP32 moduleBetter Documentation :)