commit b3a11d1eef858178f0179f2a530b271d123e221d
parent d451f2b8b391f52b9313e2071660d10d69a98b97
Author: rbckman <robinbackman@gmail.com>
Date: Sat, 24 Nov 2018 07:55:58 +0200
gui c code more comprehensive and faster
Diffstat:
3 files changed, 166 insertions(+), 416 deletions(-)
diff --git a/gui/src/main.c b/gui/src/main.c
@@ -38,447 +38,184 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
int32_t render_subtitle(GRAPHICS_RESOURCE_HANDLE img, const char *text, const uint32_t text_size, const uint32_t x_offset, const uint32_t y_offset, uint32_t fontcolor)
{
- uint32_t height=0;
- uint32_t img_w, img_h;
+ uint32_t height=0;
+ uint32_t img_w, img_h;
- graphics_get_resource_size(img, &img_w, &img_h);
+ graphics_get_resource_size(img, &img_w, &img_h);
- // split now points to last line of text. split-text = length of initial text. text_length-(split-text) is length of last line
- if (fontcolor == 5) {
- graphics_resource_render_text_ext(img, x_offset, y_offset-height,
+ // split now points to last line of text. split-text = length of initial text. text_length-(split-text) is length of last line
+ if (fontcolor == 5) {
+ graphics_resource_render_text_ext(img, x_offset, y_offset-height,
GRAPHICS_RESOURCE_WIDTH,
GRAPHICS_RESOURCE_HEIGHT,
GRAPHICS_RGBA32(225,255,255,0xff), /* fg */
GRAPHICS_RGBA32(0,0,0,0xff), /* bg */
text, 80, text_size);
- }
- if (fontcolor == 4) {
- graphics_resource_render_text_ext(img, x_offset, y_offset-height,
+ }
+ if (fontcolor == 4) {
+ graphics_resource_render_text_ext(img, x_offset, y_offset-height,
GRAPHICS_RESOURCE_WIDTH,
GRAPHICS_RESOURCE_HEIGHT,
GRAPHICS_RGBA32(51,51,51,0xff), /* fg */
GRAPHICS_RGBA32(0,0,0,0xff), /* bg */
text, 80, text_size);
- }
- if (fontcolor == 3) {
- graphics_resource_render_text_ext(img, x_offset, y_offset-height,
+ }
+ if (fontcolor == 3) {
+ graphics_resource_render_text_ext(img, x_offset, y_offset-height,
GRAPHICS_RESOURCE_WIDTH,
GRAPHICS_RESOURCE_HEIGHT,
GRAPHICS_RGBA32(30,30,255,0xff), /* fg */
GRAPHICS_RGBA32(0,0,0,0xff), /* bg */
text, 80, text_size);
- }
- if (fontcolor == 2) {
- graphics_resource_render_text_ext(img, x_offset, y_offset-height,
+ }
+ if (fontcolor == 2) {
+ graphics_resource_render_text_ext(img, x_offset, y_offset-height,
GRAPHICS_RESOURCE_WIDTH,
GRAPHICS_RESOURCE_HEIGHT,
GRAPHICS_RGBA32(255,255,255,0xff), /* fg */
GRAPHICS_RGBA32(0,0,0,0xff), /* bg */
text, 80, text_size);
- }
- if (fontcolor == 1) {
- graphics_resource_render_text_ext(img, x_offset, y_offset-height,
+ }
+ if (fontcolor == 1) {
+ graphics_resource_render_text_ext(img, x_offset, y_offset-height,
GRAPHICS_RESOURCE_WIDTH,
GRAPHICS_RESOURCE_HEIGHT,
GRAPHICS_RGBA32(0,0,0,0xff), /* fg */
GRAPHICS_RGBA32(200,200,200,0xff), /* bg */
text, 80, text_size);
- }
- return 0;
- }
+ }
+ return 0;
+ }
int main(void)
{
- GRAPHICS_RESOURCE_HANDLE img;
- uint32_t width, height;
- int LAYER=1;
- bcm_host_init();
- int s;
-
- s = gx_graphics_init(".");
- assert(s == 0);
-
- s = graphics_get_display_size(0, &width, &height);
- assert(s == 0);
-
- s = gx_create_window(0, width, height, GRAPHICS_RESOURCE_RGBA32, &img);
- assert(s == 0);
-
- // transparent before display to avoid screen flash
- graphics_resource_fill(img, 0, 0, width, height, GRAPHICS_RGBA32(0,0,0,0x00));
-
- graphics_display_resource(img, 0, LAYER, 0, 0, GRAPHICS_RESOURCE_WIDTH, GRAPHICS_RESOURCE_HEIGHT, VC_DISPMAN_ROT0, 1);
-
- uint32_t text_size = 16;
- int selected;
- int len_string_header;
- int len_string_film;
- int len_string_scene;
- int len_string_shot;
- int len_string_take;
- int len_string_rec;
- int len_string_shutter;
- int len_string_iso;
- int len_string_red;
- int len_string_blue;
- int len_string_bright;
- int len_string_cont;
- int len_string_sat;
- int len_string_flip;
- int len_string_beep;
- int len_string_lenght;
- int len_string_mic;
- int len_string_phones;
- int len_string_dsk;
- int len_string_more1;
- int len_string_more2;
- int len_string_more3;
- int len_string_more4;
- int len_string_more5;
- int len_string_more6;
- int len_string_more7;
- char check[500];
- char oldcheck[500];
- char vumeter[130];
- char menu[4];
- char header[100];
- char film[30];
- char scene[20];
- char shot[20];
- char take[20];
- char rec[20];
- char shutter[30];
- char iso[20];
- char red[20];
- char blue[20];
- char bright[20];
- char cont[20];
- char sat[20];
- char flip[20];
- char beep[20];
- char lenght[20];
- char mic[20];
- char phones[20];
- char dsk[20];
- char more1[20];
- char more2[20];
- char more3[20];
- char more4[20];
- char more5[20];
- char more6[20];
- char more7[20];
- //graphics_resource_fill(img, 0, 0, width, height, GRAPHICS_RGBA32(0,0,0,0xff));
- while (1) {
- // char ch;
- FILE *fp;
- fp = fopen("/dev/shm/vumeter","r");
- while(fgets(vumeter, 130, fp) != NULL);
- fclose(fp);
- FILE *fp2;
- fp2 = fopen("/dev/shm/interface","r");
- fgets(check, 500, fp2);
- fclose(fp2);
- // check if something has changed
- if (strcmp(check, oldcheck) != 0) {
- strcpy(oldcheck, check);
- fp2 = fopen("/dev/shm/interface","r");
- fgets(menu, 4, fp2);
- selected = atoi(menu);
- fgets(menu, 4, fp2);
- len_string_header = atoi(menu) + 1;
- fgets(header, len_string_header, fp2);
- fgets(menu, 4, fp2);
- len_string_film = atoi(menu) + 1;
- fgets(film, len_string_film, fp2);
- fgets(menu, 4, fp2);
- len_string_scene = atoi(menu) + 1;
- fgets(scene, len_string_scene, fp2);
- fgets(menu, 4, fp2);
- len_string_shot = atoi(menu) + 1;
- fgets(shot, len_string_shot, fp2);
- fgets(menu, 4, fp2);
- len_string_take = atoi(menu) + 1;
- fgets(take, len_string_take, fp2);
- fgets(menu, 4, fp2);
- len_string_rec = atoi(menu) + 1;
- fgets(rec, len_string_rec, fp2);
- fgets(menu, 4, fp2);
- len_string_shutter = atoi(menu) + 1;
- fgets(shutter, len_string_shutter, fp2);
- fgets(menu, 4, fp2);
- len_string_iso = atoi(menu) + 1;
- fgets(iso, len_string_iso, fp2);
- fgets(menu, 4, fp2);
- len_string_red = atoi(menu) + 1;
- fgets(red, len_string_red, fp2);
- fgets(menu, 4, fp2);
- len_string_blue = atoi(menu) + 1;
- fgets(blue, len_string_blue, fp2);
- fgets(menu, 4, fp2);
- len_string_bright = atoi(menu) + 1;
- fgets(bright, len_string_bright, fp2);
- fgets(menu, 4, fp2);
- len_string_cont = atoi(menu) + 1;
- fgets(cont, len_string_cont, fp2);
- fgets(menu, 4, fp2);
- len_string_sat = atoi(menu) + 1;
- fgets(sat, len_string_sat, fp2);
- fgets(menu, 4, fp2);
- len_string_flip = atoi(menu) + 1;
- fgets(flip, len_string_flip, fp2);
- fgets(menu, 4, fp2);
- len_string_beep = atoi(menu) + 1;
- fgets(beep, len_string_beep, fp2);
- fgets(menu, 4, fp2);
- len_string_lenght = atoi(menu) + 1;
- fgets(lenght, len_string_lenght, fp2);
- fgets(menu, 4, fp2);
- len_string_mic = atoi(menu) + 1;
- fgets(mic, len_string_mic, fp2);
- fgets(menu, 4, fp2);
- len_string_phones = atoi(menu) + 1;
- fgets(phones, len_string_phones, fp2);
- fgets(menu, 4, fp2);
- len_string_dsk = atoi(menu) + 1;
- fgets(dsk, len_string_dsk, fp2);
- fgets(menu, 4, fp2);
- len_string_more1 = atoi(menu) + 1;
- fgets(more1, len_string_more1, fp2);
- fgets(menu, 4, fp2);
- len_string_more2 = atoi(menu) + 1;
- fgets(more2, len_string_more2, fp2);
- fgets(menu, 4, fp2);
- len_string_more3 = atoi(menu) + 1;
- fgets(more3, len_string_more3, fp2);
- fgets(menu, 4, fp2);
- len_string_more4 = atoi(menu) + 1;
- fgets(more4, len_string_more4, fp2);
- fgets(menu, 4, fp2);
- len_string_more5 = atoi(menu) + 1;
- fgets(more5, len_string_more5, fp2);
- fgets(menu, 4, fp2);
- len_string_more6 = atoi(menu) + 1;
- fgets(more6, len_string_more6, fp2);
- fgets(menu, 4, fp2);
- len_string_more7 = atoi(menu) + 1;
- fgets(more7, len_string_more7, fp2);
- fgets(menu, 3, fp2);
- fclose(fp2);
- if (menu[0] == 'E' && menu[1] == 'O'){
- //FILE *fp3;
- //fp3 = fopen("interface.txt","r");
- //while(fgets(text3, 57, fp3) != NULL);
- //fclose(fp3);
- //const char *text = "Never give up on your dreams";
- uint32_t y_offset2 = 0;
- uint32_t y_offset3 = 21;
- uint32_t y_offset4 = 42;
- uint32_t y_offset5 = 421;
- uint32_t y_offset6 = 442;
- graphics_resource_fill(img, 0, 0, width, height, GRAPHICS_RGBA32(0,0,0,0xff));
- // blue, at the top (y=40)
- // selected 0 1 2 3 4 5 6 7 8
- int space = 10;
- int morespace = 6;
- int color = 5;
- // draw the text if updated
- if(strlen(header) != 0) {
- render_subtitle(img, header, text_size, 0, y_offset2, 5);
- if(selected == 0){
- render_subtitle(img, film, text_size, 0, y_offset3, 1);
- }
- else{
- render_subtitle(img, film, text_size, 0, y_offset3, color);
- }
- if(selected == 1){
- render_subtitle(img, scene, text_size, len_string_film * space + morespace, y_offset3, 1);
- }
- else{
- render_subtitle(img, scene, text_size, len_string_film * space + morespace, y_offset3, color);
- }
- if(selected == 2){
- render_subtitle(img, shot, text_size, len_string_film * space + len_string_scene * space + morespace * 2, y_offset3, 1);
- }
- else{
- render_subtitle(img, shot, text_size, len_string_film * space + len_string_scene * space + morespace * 2, y_offset3, color);
- }
- if(selected == 3){
- render_subtitle(img, take, text_size, len_string_film * space + len_string_scene * space + len_string_shot * space + morespace * 3, y_offset3, 1);
- }
- else{
- render_subtitle(img, take, text_size, len_string_film * space + len_string_scene * space + len_string_shot * space + morespace * 3, y_offset3, color);
- }
- if(selected == 5){
- render_subtitle(img, shutter, text_size, len_string_film * space + len_string_scene * space + len_string_shot * space + len_string_take * space + morespace * 4, y_offset3, 1);
- }
- else{
- render_subtitle(img, shutter, text_size, len_string_film * space + len_string_scene * space + len_string_shot * space + len_string_take * space + morespace * 4, y_offset3, color);
- }
- if(selected == 6){
- render_subtitle(img, iso, text_size, len_string_film * space + len_string_scene * space + len_string_shot * space + len_string_take * space + len_string_shutter * space + morespace * 5, y_offset3, 1);
- }
- else{
- render_subtitle(img, iso, text_size, len_string_film * space + len_string_scene * space + len_string_shot * space + len_string_take * space + len_string_shutter * space + morespace * 5, y_offset3, color);
- }
- }
- if(strlen(header) == 0) {
- render_subtitle(img, rec, text_size, 700, y_offset3, 3);
- if(selected == 0){
- render_subtitle(img, film, text_size, 0, y_offset2, 1);
- }
- else{
- render_subtitle(img, film, text_size, 0, y_offset2, color);
- }
- if(selected == 1){
- render_subtitle(img, scene, text_size, len_string_film * space + morespace, y_offset2, 1);
- }
- else{
- render_subtitle(img, scene, text_size, len_string_film * space + morespace, y_offset2, color);
- }
- if(selected == 2){
- render_subtitle(img, shot, text_size, len_string_film * space + len_string_scene * space + morespace * 2, y_offset2, 1);
- }
- else{
- render_subtitle(img, shot, text_size, len_string_film * space + len_string_scene * space + morespace * 2, y_offset2, color);
- }
- if(selected == 3){
- render_subtitle(img, take, text_size, len_string_film * space + len_string_scene * space + len_string_shot * space + morespace * 3, y_offset2, 1);
- }
- else{
- render_subtitle(img, take, text_size, len_string_film * space + len_string_scene * space + len_string_shot * space + morespace * 3, y_offset2, color);
- }
- if(selected == 5){
- render_subtitle(img, shutter, text_size, 0, y_offset3, 1);
- }
- else{
- render_subtitle(img, shutter, text_size, 0, y_offset3, color);
- }
- if(selected == 6){
- render_subtitle(img, iso, text_size, (len_string_shutter * space) + morespace, y_offset3, 1);
- }
- else{
- render_subtitle(img, iso, text_size, (len_string_shutter * space) + morespace, y_offset3, color);
- }
- if(selected == 7){
- render_subtitle(img, red, text_size, (len_string_shutter * space) + (len_string_iso * space) + morespace * 2, y_offset3, 1);
- }
- else{
- render_subtitle(img, red, text_size, len_string_shutter * space + len_string_iso * space + morespace * 2, y_offset3, color);
- }
- if(selected == 8){
- render_subtitle(img, blue, text_size, len_string_shutter * space + len_string_iso * space + len_string_red * space + morespace * 3, y_offset3, 1);
- }
- else{
- render_subtitle(img, blue, text_size, len_string_shutter * space + len_string_iso * space + len_string_red * space + morespace * 3, y_offset3, color);
- }
- if(selected == 9){
- render_subtitle(img, bright, text_size, 0, y_offset4, 1);
- }
- else{
- render_subtitle(img, bright, text_size, 0, y_offset4, color);
- }
- if(selected == 10){
- render_subtitle(img, cont, text_size, len_string_bright * space + morespace, y_offset4, 1);
- }
- else{
- render_subtitle(img, cont, text_size, len_string_bright * space + morespace, y_offset4, color);
- }
- if(selected == 11){
- render_subtitle(img, sat, text_size, len_string_bright * space + len_string_cont * space + morespace * 2, y_offset4, 1);
- }
- else{
- render_subtitle(img, sat, text_size, len_string_bright * space + len_string_cont * space + morespace * 2, y_offset4, color);
- }
- if(selected == 12){
- render_subtitle(img, flip, text_size, len_string_bright * space + len_string_cont * space + len_string_sat * space + morespace * 3, y_offset4, 1);
- }
- else{
- render_subtitle(img, flip, text_size, len_string_bright * space + len_string_cont * space + len_string_sat * space + morespace * 3, y_offset4, color);
- }
- if(selected == 13){
- render_subtitle(img, beep, text_size, len_string_bright * space + len_string_cont * space + len_string_sat * space + len_string_flip * space + morespace * 4, y_offset4, 1);
- }
- else{
- render_subtitle(img, beep, text_size, len_string_bright * space + len_string_cont * space + len_string_sat * space + len_string_flip * space + morespace * 4, y_offset4, color);
- }
- if(selected == 14){
- render_subtitle(img, lenght, text_size, len_string_bright * space + len_string_cont * space + len_string_sat * space + len_string_flip * space + len_string_beep * space + morespace * 5, y_offset4, 1);
- }
- else{
- render_subtitle(img, lenght, text_size, len_string_bright * space + len_string_cont * space + len_string_sat * space + len_string_flip * space + len_string_beep * space + morespace * 5, y_offset4, color);
- }
- if(selected == 15){
- render_subtitle(img, mic, text_size, 0, y_offset5, 1);
- }
- else{
- render_subtitle(img, mic, text_size, 0, y_offset5, color);
- }
- if(selected == 16){
- render_subtitle(img, phones, text_size, len_string_mic * space + morespace, y_offset5, 1);
- }
- else{
- render_subtitle(img, phones, text_size, len_string_mic * space + morespace, y_offset5, color);
- }
- if(selected == 17){
- render_subtitle(img, dsk, text_size, len_string_mic * space + len_string_phones * space + morespace * 2, y_offset5, 1);
- }
- else{
- render_subtitle(img, dsk, text_size, len_string_mic * space + len_string_phones * space + morespace * 2, y_offset5, color);
- }
- if(selected == 18){
- render_subtitle(img, more1, text_size, 0, y_offset6, 1);
- }
- else{
- render_subtitle(img, more1, text_size, 0, y_offset6, color);
- }
- if(selected == 19){
- render_subtitle(img, more2, text_size, len_string_more1 * space + morespace, y_offset6, 1);
- }
- else{
- render_subtitle(img, more2, text_size, len_string_more1 * space + morespace, y_offset6, color);
- }
- if(selected == 20){
- render_subtitle(img, more3, text_size, len_string_more1 * space + len_string_more2 * space + morespace * 2, y_offset6, 1);
- }
- else{
- render_subtitle(img, more3, text_size, len_string_more1 * space + len_string_more2 * space + morespace * 2, y_offset6, color);
- }
- if(selected == 21){
- render_subtitle(img, more4, text_size, len_string_more1 * space + len_string_more2 * space + len_string_more3 * space + morespace * 3, y_offset6, 1);
- }
- else{
- render_subtitle(img, more4, text_size, len_string_more1 * space + len_string_more2 * space + len_string_more3 * space + morespace * 3, y_offset6, color);
- }
- if(selected == 22){
- render_subtitle(img, more5, text_size, len_string_more1 * space + len_string_more2 * space + len_string_more3 * space + len_string_more4 * space + morespace * 4, y_offset6, 1);
- }
- else{
- render_subtitle(img, more5, text_size, len_string_more1 * space + len_string_more2 * space + len_string_more3 * space + len_string_more4 * space + morespace * 4, y_offset6, color);
- }
- if(selected == 23){
- render_subtitle(img, more6, text_size, len_string_more1 * space + len_string_more2 * space + len_string_more3 * space + len_string_more4 * space + len_string_more5 * space + morespace * 5, y_offset6, 1);
- }
- else{
- render_subtitle(img, more6, text_size, len_string_more1 * space + len_string_more2 * space + len_string_more3 * space + len_string_more4 * space + len_string_more5 * space + morespace * 5, y_offset6, color);
- }
- if(selected == 24){
- render_subtitle(img, more7, text_size, len_string_more1 * space + len_string_more2 * space + len_string_more3 * space + len_string_more4 * space + len_string_more5 * space + len_string_more6 * space + morespace * 6, y_offset6, 1);
- }
- else{
- render_subtitle(img, more7, text_size, len_string_more1 * space + len_string_more2 * space + len_string_more3 * space + len_string_more4 * space + len_string_more5 * space + len_string_more6 * space + morespace * 6, y_offset6, color);
- }
- }
- //graphics_update_displayed_resource(img, 0, 0, 0, 0);
- }
- }
- uint32_t y_offset = 463;
- render_subtitle(img, vumeter, text_size, 0, y_offset, 5);
- graphics_update_displayed_resource(img, 0, 0, 0, 0);
- usleep(20000);
- }
-
- graphics_display_resource(img, 0, LAYER, 0, 0, GRAPHICS_RESOURCE_WIDTH, GRAPHICS_RESOURCE_HEIGHT, VC_DISPMAN_ROT0, 0);
- graphics_delete_resource(img);
- return 0;
+ GRAPHICS_RESOURCE_HANDLE img;
+ uint32_t width, height;
+ int LAYER=1;
+ bcm_host_init();
+ int s;
+
+ s = gx_graphics_init(".");
+ assert(s == 0);
+
+ s = graphics_get_display_size(0, &width, &height);
+ assert(s == 0);
+
+ s = gx_create_window(0, width, height, GRAPHICS_RESOURCE_RGBA32, &img);
+ assert(s == 0);
+
+ // transparent before display to avoid screen flash
+ graphics_resource_fill(img, 0, 0, width, height, GRAPHICS_RGBA32(0,0,0,0x00));
+
+ graphics_display_resource(img, 0, LAYER, 0, 0, GRAPHICS_RESOURCE_WIDTH, GRAPHICS_RESOURCE_HEIGHT, VC_DISPMAN_ROT0, 1);
+
+ uint32_t text_size = 16;
+ FILE * fp;
+ FILE * fp2;
+ FILE * fp3;
+ char * line = NULL;
+ //char * b = NULL;
+ size_t len;
+ ssize_t read;
+ int linenr = 0;
+ int selected;
+ char newread[500];
+ char oldread[500];
+ char vumeter[130];
+ //graphics_resource_fill(img, 0, 0, width, height, GRAPHICS_RGBA32(0,0,0,0xff));
+ while (1) {
+ // char ch;
+ linenr = 0;
+ fp = fopen("/dev/shm/interface","r");
+ fread(newread, sizeof(char), 500, fp);
+ fclose(fp);
+ fp3 = fopen("/dev/shm/vumeter","r");
+ while(fgets(vumeter, 130, fp3) != NULL);
+ fclose(fp3);
+ // check if something has changed
+ if (strcmp(newread, oldread) != 0) {
+ strcpy(oldread, newread);
+ //const char *text = "Never give up on your dreams";
+ uint32_t y_offset2 = 0;
+ uint32_t y_offset3 = 21;
+ uint32_t y_offset4 = 42;
+ uint32_t y_offset5 = 421;
+ uint32_t y_offset6 = 442;
+ graphics_resource_fill(img, 0, 0, width, height, GRAPHICS_RGBA32(0,0,0,0xff));
+ // blue, at the top (y=40)
+ // selected 0 1 2 3 4 5 6 7 8
+ int space = 10;
+ int morespace = 12;
+ int color = 5;
+ int row1 = 0;
+ int row2 = 0;
+ int row3 = 0;
+ int row4 = 0;
+ int row5 = 0;
+ int header = 0;
+ // draw the text if updated
+ fp2 = fopen("/dev/shm/interface", "r");
+ while ((read = getline(&line, &len, fp2)) != -1) {
+ //line = b;
+ read = read - 1; //don't count the selected line
+ line[read] = '\0'; //remove return char
+ //printf("%s",line);
+ if (linenr == 0)
+ selected = atoi(line);
+ if (linenr == selected + 2)
+ color = 1; //selected color
+ else
+ color = 5; //unselected
+ if ((linenr == 1) && (read > 0))
+ header = 1; //write header menu
+ if ((linenr == 1) && (read == 0))
+ header = 0; //write normal menu
+ if (header == 0) {
+ if ((linenr == 6) && (read > 0)) //show recording time if there is any
+ render_subtitle(img, line, text_size, 700, y_offset3, 3);
+ if (linenr >= 2 && linenr <= 5){
+ render_subtitle(img, line, text_size, row1, y_offset2, color);
+ row1 += read * space + morespace;
+ }
+ if (linenr >= 7 && linenr <= 10){
+ render_subtitle(img, line, text_size, row2, y_offset3, color);
+ row2 += read * space + morespace;
+ }
+ if (linenr >= 11 && linenr <= 16){
+ render_subtitle(img, line, text_size, row3, y_offset4, color);
+ row3 += read * space + morespace;
+ }
+ if (linenr >= 17 && linenr <= 19){
+ render_subtitle(img, line, text_size, row4, y_offset5, color);
+ row4 += read * space + morespace;
+ }
+ if (linenr >= 20 && linenr <= 32){
+ render_subtitle(img, line, text_size, row5, y_offset6, color);
+ row5 += read * space + morespace;
+ }
+ }
+ if (header == 1) {
+ if (linenr == 1)
+ render_subtitle(img, line, text_size, 0, y_offset2, 5);
+ if (linenr > 1) {
+ render_subtitle(img, line, text_size, row1, y_offset3, color);
+ row1 += read * space + morespace;
+ }
+ }
+ linenr += 1;
+ free(line);
+ line = NULL;
+ }
+ fclose(fp2);
+ //graphics_update_displayed_resource(img, 0, 0, 0, 0);
+ }
+ uint32_t y_offset = 463;
+ render_subtitle(img, vumeter, text_size, 0, y_offset, 5);
+ graphics_update_displayed_resource(img, 0, 0, 0, 0);
+ usleep(20000);
+ }
+ graphics_display_resource(img, 0, LAYER, 0, 0, GRAPHICS_RESOURCE_WIDTH, GRAPHICS_RESOURCE_HEIGHT, VC_DISPMAN_ROT0, 0);
+ graphics_delete_resource(img);
+ return 0;
}
diff --git a/gui/tarinagui.bin b/gui/tarinagui.bin
Binary files differ.
diff --git a/tarina.py b/tarina.py
@@ -80,7 +80,7 @@ def loadsettings(filmfolder, filmname):
#--------------Write the menu layer to dispmanx--------------
-def writemenu(menu,settings,selected,header):
+def writemenu_old(menu,settings,selected,header):
menudone = ''
menudone += str(selected).zfill(3)
menudone += str(len(header)).zfill(3) + header
@@ -94,13 +94,26 @@ def writemenu(menu,settings,selected,header):
f.write(menudone)
f.close()
+def writemenu(menu,settings,selected,header):
+ menudone = ''
+ menudone += str(selected) + '\n'
+ menudone += header + '\n'
+ for i, s in zip(menu, settings):
+ menudone += i + s + '\n'
+ spaces = len(menudone) - 500
+ menudone += spaces * ' '
+ #menudone += 'EOF'
+ f = open('/dev/shm/interface', 'w')
+ f.write(menudone)
+ f.close()
+
#------------Write to screen----------------
def writemessage(message):
menudone = ""
- menudone += '000'
- menudone += str(len(message)).zfill(3) + message
- menudone += 'EOF'
+ menudone += '0' + '\n'
+ menudone += message + '\n'
+ #menudone += 'EOF'
#clear = 500
#clear = clear - len(message)
f = open('/dev/shm/interface', 'w')