Hi, Habr. Remembering my engineering youth, I wanted to look around the glands again. Returning to PIC'acm and programming on asm was frankly lazy (traumatic childhood memories of manual work without third-party libraries with i2c and HD44780 bus), so I went online and found out about the existence of the Arduino platform.
A quick glance showed that this is just what I need to satisfy the nostalgic urges. A week ago, a set was purchased. To flash the LED to the former engineer of electronics with five years of experience is somehow not comme il faut, that's why the idea of ​​a statistics gauge in tanks was born (I confess, it’s a sin ...). This is my peculiar “Hello, Habr!” And “Hello, World!”. The idea is simple - monitor the Wargaming statistics server and notify the user about his game successes (or vice versa). I decided to monitor with the help of the Wargaming API, since the idea of ​​parsing web pages of foreign resources rested on the size of the RAM (8kb per receive) used to access the shield on the W5100 controller. ')
To display the information I took what was at hand - the standard 1602 display. But that would not be too trivial, I decided to connect it via the shift register 74HC595. A quick search proved the old truth that everything has already been invented before us: link . The display sits on the SPI bus and additionally uses one pin to select the device (I have the 3rd). For successful compiling, you need to replace the LiquidCrystal library with the modified one from the link above. Also, by the link above, the author forgot to put the r / w pin of the display on the ground, which is why he initially thought that the example was not working. Just in case my crazy board:
Breadboard
I also wanted to implement the logging of achievements on the SD card, but decided to leave for the future, as well as a small web server with monitoring results.
// Repeat until buffer is empty while (client.available ()) { // Read the byte from the buffer pre_symbol = symbol; symbol = client.read (); //Serial.print (symbol); if (ReadStatus == WiteTag && pre_symbol == '"' && symbol! = ':') { // Found the beginning of the tag ReadStatus = ReadTag; TagName = ""; }
if (ReadStatus == ReadTag) { if (symbol! = '"') { // Read the tag name TagName + = symbol; } else { // Found end of tag Value = ""; ReadStatus = WiteValue; } }
if (ReadStatus == WiteValue) { if (symbol == ',' || symbol == '}') { // End of value ReadStatus = WiteTag; FilterData (SectionTagName, TagName, Value); if (symbol == '}') { // End of section SectionTagName = PreSectionTagName; } } else { if (symbol == '{') { // Start section PreSectionTagName = SectionTagName; SectionTagName = TagName; ReadStatus = WiteTag; } else { // Read the value if (symbol! = ':' && symbol! = '"' && symbol! = '') Value + = symbol; } } } } } // Stop Client client.flush (); client.stop (); }
But a demonstration of work. Unfortunately, Wargaming servers update statistics only after the game session ends:
And finally, a fly in the ointment - for reasons I don't understand, after a while, the device stops taking statistics from the server.By debag and indicators, it is clear that the request is leaving, but there is no answer.I hope this is due to my crooked tuned router. Upd. No longer relevant, corrected sketch