These are chat archives for SmingHub/Sming

21st
Jan 2016
Sébastien
@sle118
Jan 21 2016 04:40
I have a working jpeg display class now! Woot! But... I am not satisfied. I will reimplement using stb_image instead
Sébastien
@sle118
Jan 21 2016 04:49
This library is far more powerful and can read many more pictures formats (including png) as well as convert on the fly to lower number of components per pixels. For example to get gray scale data. It also recognizes the file type by parsing the header before decoding! I am curious to see how much space it's going to consume...
Sébastien
@sle118
Jan 21 2016 04:57
In the meantime, if anyone is interested i am willing to share existing code for current rough implement of jpeg display
alonewolfx2
@alonewolfx2
Jan 21 2016 06:29
@sle118 can we use your code with sdcard ?
and if you share i want to try it
alonewolfx2
@alonewolfx2
Jan 21 2016 07:14
@sle118 and can we use on full color tft screen like ili9341
hreintke
@hreintke
Jan 21 2016 07:45
@sle118 : Why would you use FastDelegate when there is already a Delegate in SmingCore ?
alon24
@alon24
Jan 21 2016 09:00
@sle118 you putting u'r code into info screens?
Sébastien
@sle118
Jan 21 2016 11:49
@sle118 can we use your code with sdcard ?
Yes as longs as you can read from file
@sle118 and can we use on full color tft screen like ili9341
I have not tried, but yes most likely. I implemented a callback to draw pixel with rgb components
@sle118 : Why would you use FastDelegate when there is already a Delegate in SmingCore ?
Because no one was there yesterday to point me to the capability
Look
Lol
But i ended up with a different solution as the picojpeg was using static variables and want suitable for multi instance
robotiko
@robotiko
Jan 21 2016 11:52
@sle118 there are several example in sming using delegates
do you need any addtional help there?
Sébastien
@sle118
Jan 21 2016 11:53
@sle118 you putting u'r code into info screens?
Not yet
robotiko
@robotiko
Jan 21 2016 11:53
even in infoscreens (if you saw it ) there are many delegate usages
Sébastien
@sle118
Jan 21 2016 11:53
I will work on s much better implementation with multi format image reader
robotiko
@robotiko
Jan 21 2016 11:54
@sle118 need any addtional info about delegates?
Sébastien
@sle118
Jan 21 2016 11:54
Likely not for now
I'll have breakfast and be right back to share my code
Will check in to git
Sébastien
@sle118
Jan 21 2016 12:14
@sle118 need any addtional info about delegates?
Do these allow passing the address of an instance member function?
robotiko
@robotiko
Jan 21 2016 12:15
sure
Sébastien
@sle118
Jan 21 2016 12:16
The issue i faced was that the compiler was complaining about typing
Since the picojpeg library was asking for a static unsigned char function
I didn't want to touch the library code either but i guess i could have added a void pointer to pass "this"
Back to the delegate
hreintke
@hreintke
Jan 21 2016 12:20
@sle118 : When it is a delegate you can just pass the void pointer in the call.
Sébastien
@sle118
Jan 21 2016 13:15
@hreintke Agreed with this
I guess I was looking for a way to create a delegate that would be transparent to the base implementation of the picojpeg decoder so that I would not have to change it
but anyhow as I said, the decoded used one main static variable for the buffer and thus wasn't thread safe
alon24
@alon24
Jan 21 2016 13:43
i guess if we saw the code ... hint hint....
Sébastien
@sle118
Jan 21 2016 13:58
lol
here is the link to the jpeg display library
you can place it inside Sming/Sming/Libraries
and rebuild Sming
Sébastien
@sle118
Jan 21 2016 14:48
ok and here is an example for the library https://github.com/sle118/JPEGDecoderExample
This message was deleted
enjoy!
next on the list is a port of a more powerful library
riban-bw
@riban-bw
Jan 21 2016 14:52
@robotiko I tried to add API docs to the delegate.h file but realised I didn't know what I was doing!!! I started to look up what delegate is (Google / Wikipedia) but any help from this community would help. It is the first class that I have really struggled to understand. I am not sure what the difference is between a classic c-type callback (used in some parts of the framework) and a delegate.
Sébastien
@sle118
Jan 21 2016 14:55
the main difference is that a delegate has a dynamic address as opposed to a static C callback
so the delegate helps resolve the current instance (this) of the function address being called
otherwise the class member function would not be able to access its instance data
but maybe someone else has a better definition to offer
does this make sense?
in a typical static function, memory is pre-allocated by the compiler and variables are available on the function's stack
this isn't the case with classes instances, where instance variables are stored in a memory structure which is pointed to with "this"
alonewolfx2
@alonewolfx2
Jan 21 2016 17:30
@sle118 did you upload library? or make PR for jpegdecoder library?
Sébastien
@sle118
Jan 21 2016 19:26
@sle118 did you upload library? or make PR for jpegdecoder library?
I uploaded to my own git for now
I have created a better implementation
robotiko
@robotiko
Jan 21 2016 19:41
@sle118 where did you get that nodemcu devkit board with chip antenna?
can you use gpio9?
alonewolfx2
@alonewolfx2
Jan 21 2016 19:49
@robotiko haha still gpio9 :)
robotiko
@robotiko
Jan 21 2016 19:59
@alonewolfx2 life sucks
sometimes ;)
:D
Sébastien
@sle118
Jan 21 2016 20:00
@sle118 where did you get that nodemcu devkit board with chip antenna?
it took a while to get them
robotiko
@robotiko
Jan 21 2016 20:00
first time I see
Sébastien
@sle118
Jan 21 2016 20:00
but I had researched ESP variants before ordering
robotiko
@robotiko
Jan 21 2016 20:00
I looked for them
months ago
what esp12 is is e/d/f?
this one's an esp07
alonewolfx2
@alonewolfx2
Jan 21 2016 20:01
its esp07 i think
Sébastien
@sle118
Jan 21 2016 20:01
with 4M flash
robotiko
@robotiko
Jan 21 2016 20:01
yes man .. but this is the first nodemcu with chip antenna I see
what?!
Sébastien
@sle118
Jan 21 2016 20:01
AND an external antenna connector/ceramic
robotiko
@robotiko
Jan 21 2016 20:01
wtf
:D
Sébastien
@sle118
Jan 21 2016 20:02
your life will change forever now ;)
robotiko
@robotiko
Jan 21 2016 20:02
not rally
really
cannot live with 4M
rboot and heavy html content rules
stb_image library is now wrapped into Sming on my local machine
he he he
alonewolfx2
@alonewolfx2
Jan 21 2016 20:07
whaaat :)
can we make pr :D
Sébastien
@sle118
Jan 21 2016 20:07
soon
I am testing now
I think it's leaking somewhere
how can I dump system status on serial? looking for memory usage
alonewolfx2
@alonewolfx2
Jan 21 2016 20:10
@sle118 c'mon i am waiting for test :D
f5ef917d-a6d1-4791-ab89-14914dacc944.jpg
Sébastien
@sle118
Jan 21 2016 20:11
are these burn marks from soldering?
alonewolfx2
@alonewolfx2
Jan 21 2016 20:11
yep. i forget that. it was so hot and it burned
but stil working very good :D
Sébastien
@sle118
Jan 21 2016 20:13
i wish I could fix my 2 faulting OLEDS
I'll inspect connections
they aren't showing odd lines
Sébastien
@sle118
Jan 21 2016 20:25
stbi is 15% faster than my previous implementation
34micro second to display a 32x32 jpg
vs 40us or so
robotiko
@robotiko
Jan 21 2016 20:29
34us in decoding the jpg? nice
Sébastien
@sle118
Jan 21 2016 20:29
yes
pretty good but I am in the darl
dar
k
robotiko
@robotiko
Jan 21 2016 20:29
and whole screen=
Sébastien
@sle118
Jan 21 2016 20:29
I don't know how to check memory usage on this
robotiko
@robotiko
Jan 21 2016 20:29
?
one sec
is soemthing like heapdump
Sébastien
@sle118
Jan 21 2016 20:30
so I decode 3JPG 32x32 so 32x96 in 100us
robotiko
@robotiko
Jan 21 2016 20:31
and less heavy algorythm?
Sébastien
@sle118
Jan 21 2016 20:31
it's actually more complex
robotiko
@robotiko
Jan 21 2016 20:31
png?
Sébastien
@sle118
Jan 21 2016 20:31
the difference with the other is that this one processes the entire file in one chunk
so more memory intensive
png supposed to work
and gif
robotiko
@robotiko
Jan 21 2016 20:32
do you have a stick to take alonewolfx2 down?
:D
Sébastien
@sle118
Jan 21 2016 20:33
here are the specs of stb_image
  JPEG baseline & progressive (12 bpc/arithmetic not supported, same as stock IJG lib)
  PNG 1/2/4/8-bit-per-channel (16 bpc not supported)

  TGA (not sure what subset, if a subset)
  BMP non-1bpp, non-RLE
  PSD (composited view only, no extra channels, 8/16 bit-per-channel)

  GIF (*comp always reports as 4-channel)
  HDR (radiance rgbE format)
  PIC (Softimage PIC)
  PNM (PPM and PGM binary only)
it's not my work
I am just wrapping it in Sming
robotiko
@robotiko
Jan 21 2016 20:34
Serial.printf("Free Heap: %d\r\n", system_get_free_heap_size());
Sébastien
@sle118
Jan 21 2016 20:34
/* stb_image - v2.09 - public domain image loader - http://nothings.org/stb_image.h
@robotiko thanks!
robotiko
@robotiko
Jan 21 2016 20:35
I think that is what you need
and for timing
I use this
uint32_t systemTime = RTC.getRtcSeconds();
// My weird process 

int elapsedSecs = (RTC.getRtcSeconds()-systemTime);
debugf("%s  - Processed  in %d:%d mins total %d secs  \n",SystemClock.now().toShortTimeString(true).c_str(),(int)(elapsedSecs / 60),(elapsedSecs%60),elapsedSecs);
but that is for seconds
can get the us
robotiko
@robotiko
Jan 21 2016 20:40
with unsigned long micros(void);
for porer measure
proper
laurentppol
@laurentppol
Jan 21 2016 20:58
anyone could point me to (Espressif) doc about: hwtimer, ADC?
which one of them
alonewolfx2
@alonewolfx2
Jan 21 2016 21:12
@laurentppol what do you need
hwtimer port maded from @hreintke
adc is 1v scaled
laurentppol
@laurentppol
Jan 21 2016 21:13
in which of Espressif hwtimer / adc is described?
"how they made it"
alonewolfx2
@alonewolfx2
Jan 21 2016 21:14
i know just its in soc
i dont know low level hw side
laurentppol
@laurentppol
Jan 21 2016 21:16
especially for ADC: is there an interrupt ("real" - hardware), what max sps, etc details
as available for AVR in Atmel DS
robotiko
@robotiko
Jan 21 2016 21:33
@laurentppol you have it on espressif bbs under docs
the adc is just shit
0-1v
if seems that wifi interferes with readings
etc
Sébastien
@sle118
Jan 21 2016 21:44
I am having fun with the image library
except it reboots my ESP after a few rounds
not sure how to troubleshoot thiss
robotiko
@robotiko
Jan 21 2016 21:46
looks like
loops hughing cpu
or delay in loops etc
arduino stuff
Sébastien
@sle118
Jan 21 2016 21:46
ok
I have a timer that refreshes the display and re-display the jpg
it runs 2 times and boom reboot
so some stack is messed up somewhere
I'll check for rogue pointer logic
robotiko
@robotiko
Jan 21 2016 21:47
if you set it to tight.. and doesnt finish first rebder when you call second
can happen
Sébastien
@sle118
Jan 21 2016 21:47
ok
robotiko
@robotiko
Jan 21 2016 21:47
you bbeter use a delegate
Sébastien
@sle118
Jan 21 2016 21:47
so I'll stop the timer and restart it when done
you bbeter use a delegate
:P
robotiko
@robotiko
Jan 21 2016 21:48
in the drawing function
yes .. already drunk :DDD
@sle118 your repo is not updated ..
to have a fast look
Sébastien
@sle118
Jan 21 2016 21:50
I haven't put the image lib in my repo just yet
robotiko
@robotiko
Jan 21 2016 21:51
yes
nothing to see in the link you provided to your repo
mainly becuase the example is quite trivial
and it is includign soemthign that is under sming libs
but there is no sming fork
JPEGDecoder.. is not tuned for sming?
Sébastien
@sle118
Jan 21 2016 21:53
so
JPEGDecoder works pretty well
and the example is complete
so you are free to use it : get the library and save it under Sming/Libraries
I was not satisfied with the decoder
robotiko
@robotiko
Jan 21 2016 21:54
ok
Sébastien
@sle118
Jan 21 2016 21:54
so I found a better open source library
from stb
which I have wrapped inside a new library
robotiko
@robotiko
Jan 21 2016 21:55
I was just goign to have a fast look to see possible reset reasons
Sébastien
@sle118
Jan 21 2016 21:55
I could create a new branch of my example
and possibly also branch Sming
robotiko
@robotiko
Jan 21 2016 21:56
if you leave the lib as included in your project ..
dotn need to branch sming.. otherwise .. you have to
wrapper.. hum
no timing inside the lib i guess
Sébastien
@sle118
Jan 21 2016 21:58
I am creating a dev branch for JPEGDecoderExample
well
I thought I created a new branch... anyhow my changes are now committed to https://github.com/sle118/JPEGDecoderExample
I have not yet committed the lib
robotiko
@robotiko
Jan 21 2016 22:04
the code .. unless there is null or something like
doesn't look like cause of rst ..
has no delays..
just the loop for drawing pixels..
Sébastien
@sle118
Jan 21 2016 22:04
yep
robotiko
@robotiko
Jan 21 2016 22:05
and .. timer is every 3 secos
secs so if it just takes us to draw..
checked that fors are always under good values?
looks like
Sébastien
@sle118
Jan 21 2016 22:08
ok
definitely the decoding wrapper that's causing the issue
maybe it's stressing memory too much?
it's malloc'ing 10k for the output buffer
not sure how much this leaves to the rest of the os
alonewolfx2
@alonewolfx2
Jan 21 2016 22:09
@sle118 can you try to fee wdt i nloop
Sébastien
@sle118
Jan 21 2016 22:11
is memory freed in an instant after calling "free", or is there some garbage collection?
I think pointer logic is the issue here most likely
I am going to try the decode without the draw
ok decode alone called multiple times crashes
I'll remove logic bits one at a time just to see.
hreintke
@hreintke
Jan 21 2016 22:15
@sle118 : There is no garbage collection. Freeing memory does what it says.
Sébastien
@sle118
Jan 21 2016 22:16
this is what I thought
does malloc take memory from the heap?
calling Serial.printf("Free Heap: %d\r\n", system_get_free_heap_size());
hreintke
@hreintke
Jan 21 2016 22:17
But malloc 10K for a buffer will not work for sure
Sébastien
@sle118
Jan 21 2016 22:17
before and after free doesn't have much difference
ah
tell me
?
malloc doesn't complain
hreintke
@hreintke
Jan 21 2016 22:19
I am not sure what the absolute maximums are but it is a memory constrained device
Sébastien
@sle118
Jan 21 2016 22:24
where is malloc grabbing memory from, and how do we check how much is available before calling it?
i thought this was the way: system_get_free_heap_size()
here is some data from this function
This message was deleted
BEFORE IMAGE LOAD - Free Heap: 37736
AFTER OPEN FILE - Free Heap: 37672
AFTER IMAGE LOAD - Free Heap: 36664
AFTER STB FREE - Free Heap: 37712
so 10k doesn't seem to be an issue?
hreintke
@hreintke
Jan 21 2016 22:44
Did a quick test
I use : int h = xPortGetFreeHeapSize(); for finding available space
when using :
`char* buf; buf = (char*)malloc(10000);
it stays around the same
when using char* newbuf = new char[10000];
it goes down every call.
Sébastien
@sle118
Jan 21 2016 22:48
ok I tried
it is aligned to system_get_free_heap_size
maybe it's a stack issue
i.e. not sure where the timer is called from
ok
not caused by timer
hreintke
@hreintke
Jan 21 2016 22:49
that is where the "NON OS" kicks in
Sébastien
@sle118
Jan 21 2016 22:53
allright
something happens when the OS is doing stuff in the background
the crash happens when WIFI is being worked on
oh
nevermind that
hreintke
@hreintke
Jan 21 2016 22:54
How are you manipulating the buffer ?
Sébastien
@sle118
Jan 21 2016 22:54
I think the loader is corrupting the memory
and then when the os needs to start something, memory is corrupted already
I let the library deal with decoding
and read the buffer/free it
hreintke
@hreintke
Jan 21 2016 22:56
In timer you have to be careful with "loop processing" will cause watchdog resets
Sébastien
@sle118
Jan 21 2016 22:56
I moved everything out and into the init() just to be sure
hreintke
@hreintke
Jan 21 2016 22:58
tested to be sure . my xPortGetFreeHeapSize() returns exactly the same figure as system_get_free_heap_size()
I am out for now.
If you have questions/things that you want me to test. Just leave a message here and I will do tomorrow CET.
Sébastien
@sle118
Jan 21 2016 23:01
ok
thanks