olikraus / m2tklib

Automatically exported from code.google.com/p/m2tklib
Other
49 stars 11 forks source link

File Menu Example #134

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Load File menu example

What is the expected output? What do you see instead?
File browser list only uses 1/2 the display, should be all

What version of the product are you using? On what operating system?
Teensy 3.1 with 128x64 OLED SSD1306 with u8glib - Arduino IDE

Please provide any additional information below.
I have everything working but just can't find the code that will adjust it to 
use the entire display. I am integrating the example into my code base. And the 
file browser is called from the main menu. The file list show up half way down 
the display.

Thanks.

Original issue reported on code.google.com by blackspa...@gmail.com on 30 Apr 2014 at 6:09

GoogleCodeExporter commented 9 years ago
What is your current constructor for U8glib?
Can you procide the full example code which produces the bug?

Original comment by olikr...@gmail.com on 30 Apr 2014 at 9:47

GoogleCodeExporter commented 9 years ago
Here is what I am using because I created a com addon to use hardware SPI on 
Teeensy

U8GLIB u8g(&u8g_dev_ssd1306_128x64_2x_hw_spi, u8g_com_hw_spi_fn);

The rest of the file select example is unchanged except for the Slave select 
pin which I am using 2. 

I can post the rest when I get home in 2hrs. 

Thanks.

Original comment by blackspa...@gmail.com on 30 Apr 2014 at 10:02

GoogleCodeExporter commented 9 years ago
I should mention I am using the Arduino SD library.

Original comment by blackspa...@gmail.com on 30 Apr 2014 at 10:03

GoogleCodeExporter commented 9 years ago
Is it possible to attache a picture of the "File List" also?

Original comment by olikr...@gmail.com on 30 Apr 2014 at 10:31

GoogleCodeExporter commented 9 years ago
Here is a picture what is happening. 

This image is it running with my code but it does the same time with the 
example code. 

The ultimate goal is have it start at the top and stop just above the status 
bar. I take it shouldn't be too hard to filter to certain files, like .txt.

Thanks.

Original comment by blackspa...@gmail.com on 1 May 2014 at 1:21

Attachments:

GoogleCodeExporter commented 9 years ago
Now it would be interessting to see the corresponding code also.

Original comment by olikr...@gmail.com on 1 May 2014 at 5:11

GoogleCodeExporter commented 9 years ago
Well here is the code based on the example that has the display problem. This 
is without my code, just the needed changes for my hardware.

Original comment by blackspa...@gmail.com on 1 May 2014 at 5:19

Attachments:

GoogleCodeExporter commented 9 years ago
hmmm... 
What about using
M2_STRLIST(el_fs_strlist, "l4F3e15W46", &fs_m2tk_first, &fs_m2tk_cnt, 
fs_strlist_getstr);
instead of
M2_STRLIST(el_fs_strlist, "l3F3e15W46", &fs_m2tk_first, &fs_m2tk_cnt, 
fs_strlist_getstr);
(see line 226)

Of course this is not a bug. The file list has been instructed to use only 3 
lines ("l3" option) in this example. 

Will this solve your problem?

Regarding the text filter: It is probably the easiest way to modify functions
uint8_t mas_sd_get_nth_file(const char *path, uint16_t n, char *buf, uint8_t 
*is_dir)
and
uint16_t mas_sd_get_directory_file_cnt(const char *path)
in
  mas_arduino_sd.c
and skip any none ".txt" files.

Original comment by olikr...@gmail.com on 1 May 2014 at 5:50

GoogleCodeExporter commented 9 years ago
Thanks! I know I played with those values but now I realized why it didn't work 
before. I was reading it as 13 instead l3

How can I get it to not use the last row on the display?

Hmm, that is what I was thinking to modify the function. I will give it a try 
but only thing with that is I will have to include my own version of the 
library with the source code. 

Original comment by blackspa...@gmail.com on 1 May 2014 at 5:59

GoogleCodeExporter commented 9 years ago
> How can I get it to not use the last row on the display?
Not sure what you mean. The strlist element is centered on the display (see the 
correspinding allign statement). 

Original comment by olikr...@gmail.com on 1 May 2014 at 6:30

GoogleCodeExporter commented 9 years ago
I meant so that the list doesn't go all the way to the bottom of the display. 
So say you have 4 lines then 1 blank at the bottom. 

Original comment by blackspa...@gmail.com on 1 May 2014 at 6:32

GoogleCodeExporter commented 9 years ago
i was wrong, some comments above. The fileselection is not centered.
Currently it is like this:

M2_STRLIST(el_fs_strlist, "l3F3e15W46", &fs_m2tk_first, &fs_m2tk_cnt, 
fs_strlist_getstr);
M2_SPACE(el_fs_space, "W1h1");
M2_VSB(el_fs_strlist_vsb, "l3W2r1", &fs_m2tk_first, &fs_m2tk_cnt);
M2_LIST(list_fs_strlist) = { &el_fs_strlist, &el_fs_space, &el_fs_strlist_vsb };
M2_HLIST(el_top_fs, NULL, list_fs_strlist);

The file list itself is the strlist element. which is embedded into the left 
side of a hlist (second element of the hlist is the scrollbar)

By default the hlist is placed at the bottom of the screen. That means you need 
to place the hlist element at a different position. There are several options 
to do this.
1) if there are no further elements on the screen (that means you manually want 
to draw on the screen with u8glib), then  you could embed (call hlist) from an 
align element:
M2_ALIGN(my_file_select, "-1|1W64H64", &el_top_fs);
Option of the align statement will give you full controll of the position of 
el_top_fs.
2) use XYLIST and assign position manually
3) use VLIST and place the file selection box as first element and other 
elemtns (your empty line) as second list element of the VLIST

/*=========================================================================*/
/* a simple main menu for the file select */

M2_ROOT(el_start, NULL, "File Selection", &el_top_fs);
M2_ALIGN(top_el_start, "-1|1W64H64", &el_start);

Original comment by olikr...@gmail.com on 1 May 2014 at 6:45

GoogleCodeExporter commented 9 years ago
Thank you so much adding the HLIST to an ALIGN object worked well. 

Tomorrow I will play with filtering the file type. I started with it but can't 
figure out to get the current file name from the file object.

I think I am finally getting the hang of this. Pretty powerful library. Almost 
like Visual Basic GUI for uC's.

Original comment by blackspa...@gmail.com on 1 May 2014 at 7:00

GoogleCodeExporter commented 9 years ago
> I started with it but can't figure out to get the current file name from the 
file object.
Should be "f.name()". But my knowledge on the SD.h is very limited.

Original comment by olikr...@gmail.com on 1 May 2014 at 7:23

GoogleCodeExporter commented 9 years ago
Thanks that worked well. I had looked for it online but couldn't find anything. 
.name() isn't listed on the Arduino ref pages. I will moving to the SdFat 
library soon, freed up a bunch of flash on another project.

Now I just need to finish the file handling stuff once you select a file. 

Thank you for your help. 

Original comment by blackspa...@gmail.com on 1 May 2014 at 4:38

GoogleCodeExporter commented 9 years ago
Yes, SdFat is faster and requires less flash memory.

Original comment by olikr...@gmail.com on 1 May 2014 at 5:06

GoogleCodeExporter commented 9 years ago
Side question,

If you delete a file how can I can refresh the file listing when I jump back to 
the file list?

When I go back the file is still listed.

Thanks, almost got everything I need.

Original comment by blackspa...@gmail.com on 2 May 2014 at 6:11

GoogleCodeExporter commented 9 years ago
Oh,i missed this question.

If i remember correctly, then
m2.setKey(M2_KEY_REFRESH)
or
m2_SetKey(M2_KEY_REFRESH)
should do this.
Otherwise simple do a m2.draw() on the screen.

Original comment by olikr...@gmail.com on 5 May 2014 at 7:32

GoogleCodeExporter commented 9 years ago
Thanks, will this refresh reading the files from the SD Card? What happens is 
that I delete or add a file and the file list doesn't show it the change.

Original comment by blackspa...@gmail.com on 5 May 2014 at 7:35

GoogleCodeExporter commented 9 years ago
If you delete or add a file, then this should be visible as soon as you do a 
redraw.
Is the actual behavior different?

Original comment by olikr...@gmail.com on 5 May 2014 at 7:44

GoogleCodeExporter commented 9 years ago
So far it hasn't been. The screen is redrawn every loop so it should update 
when I go back to the list menu. 

I can double check when I get home. But when I worked on it last I had to power 
rest to refresh contents of SD card. 

Original comment by blackspa...@gmail.com on 5 May 2014 at 8:10

GoogleCodeExporter commented 9 years ago
m2tklib always reads from the SD card library. But maybe there is some 
chaching...

Original comment by olikr...@gmail.com on 5 May 2014 at 8:54

GoogleCodeExporter commented 9 years ago
Okay, I will look in to SdFat and see if there is anything there I can call.

Original comment by blackspa...@gmail.com on 5 May 2014 at 8:56

GoogleCodeExporter commented 9 years ago
So far I haven't found anything. I posted in the Arduino Forum to see if anyone 
else has run into this issue. 

Original comment by blackspa...@gmail.com on 6 May 2014 at 1:44

GoogleCodeExporter commented 9 years ago
I realized that on this code I am still using Arduino SD library. It was the 
other code that has SdFat lol. Everything is getting mixed in my head.

I think I should switch to SdFat first.

Original comment by blackspa...@gmail.com on 6 May 2014 at 5:26

GoogleCodeExporter commented 9 years ago
In the Sdfat version how can I get the file name so I can do the filtering for 
.txt?

Thanks.

Original comment by blackspa...@gmail.com on 6 May 2014 at 5:36

GoogleCodeExporter commented 9 years ago
I think it is best to have a look at 
"http://code.google.com/p/m2tklib/source/browse/dev/sdfat/mas_sdfat.cpp"

I did get the filename with "getFilename", which copies the filename to an 
internal buffer.

For the filte, i guess you could update 
mas_sdfat_get_nth_file(const char *path, uint16_t n, char *buf, uint8_t 
*is_dir) 

Original comment by olikr...@gmail.com on 6 May 2014 at 6:49

GoogleCodeExporter commented 9 years ago
Well I got SDFat working. The examples for Sdfat work but doesn't seem to work 
with M2klib, the example doesn't list any files. Same with my code. hmmm. I 
switched everything over and change the init to 

mas_Init(mas_device_sdfat, (void *)&sd);

Any ideas?

Original comment by blackspa...@gmail.com on 6 May 2014 at 6:52

GoogleCodeExporter commented 9 years ago
Sorry, figured it out. I commented out my filter but forgot I wasn't editing 
the version inside the utility folder. So the problem is my filter.

I was using the same code from the SD version.

I still need to edit both functions right?

mas_sdfat_get_nth_file
mas_sdfat_get_directory_file_cnt

Original comment by blackspa...@gmail.com on 6 May 2014 at 7:10

GoogleCodeExporter commented 9 years ago
At least the fresh issue is gone. So its only an issue with the Arduino SD 
library at least for the Teensy. Good to know if someone else runs into that. 

Original comment by blackspa...@gmail.com on 6 May 2014 at 7:12

GoogleCodeExporter commented 9 years ago
thanks for reporting all this

Original comment by olikr...@gmail.com on 6 May 2014 at 5:12

GoogleCodeExporter commented 9 years ago
No problem, last night I still couldn't get the file filter to work with the 
Sdfat mas addon. Have to work on it when it isn't midnight. ;)

Original comment by blackspa...@gmail.com on 6 May 2014 at 5:14