tarina

git clone https://git.tarina.org/tarina
Log | Files | Refs | README | LICENSE

commit 5088ea4f8bade92419f463a66ea0701d05ef8652
parent 71fd1d0f02e20b5aad6fc72a1681d337b02f8583
Author: rbckman <robinbackman@gmail.com>
Date:   Thu, 19 Jan 2017 23:35:31 +0000

new written menu gui

Diffstat:
Mtarina.py | 167+++++++++++++++++++++++++++++++++++++++++++------------------------------------
Mvc/src/hello_pi/hello_interface/camerainterface.bin | 0
Mvc/src/hello_pi/hello_interface/main.c | 390+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------
Avc/src/hello_pi/hello_interface/mainold.c | 170+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 593 insertions(+), 134 deletions(-)

diff --git a/tarina.py b/tarina.py @@ -60,14 +60,14 @@ def loadscenesettings(filmfolder, filmname, scene, shot): #--------------Write the menu layer to dispmax-------------- -def writemenu(menu,settings,selected,header): +def writemenuold(menu,settings,selected,header): c = 0 - clear = 305 + clear = 360 menudone = '' - firstline = 18 + firstline = 45 if header != '': header = ' ' + header - spaces = 61 - len(header) + spaces = 72 - len(header) header = header + (spaces * ' ') firstline = 45 for a in menu: @@ -82,26 +82,40 @@ def writemenu(menu,settings,selected,header): menudone = menudone + ' ' c = c + 1 if len(menudone) > firstline: - spaces = 61 - len(menudone) + spaces = 72 - len(menudone) menudone = menudone + spaces * ' ' - if len(menudone) > 102: - spaces = 122 - len(menudone) + if len(menudone) > 113: + spaces = 144 - len(menudone) menudone = menudone + spaces * ' ' - if len(menudone) > 170: - spaces = 183 - len(menudone) + if len(menudone) > 192: + spaces = 216 - len(menudone) menudone = menudone + spaces * ' ' - if len(menudone) > 208: - spaces = 244 - len(menudone) + if len(menudone) > 241: + spaces = 288 - len(menudone) menudone = menudone + spaces * ' ' f = open('/dev/shm/interface', 'w') clear = clear - len(menudone) f.write(header + menudone + clear * ' ') f.close() +def writemenu(menu,settings,selected,header): + menudone = '' + menudone += str(selected).zfill(3) + menudone += str(len(header)).zfill(3) + header + for i, s in zip(menu, settings): + menudone += str(len(i) + len(s)).zfill(3) + menudone += i + s + 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): - clear = 305 + clear = 360 clear = clear - len(message) f = open('/dev/shm/interface', 'w') f.write(' ' + message + clear * ' ') @@ -110,7 +124,7 @@ def writemessage(message): #------------Write to vumeter (last line)----- def vumetermessage(message): - clear = 61 + clear = 72 clear = clear - len(message) f = open('/dev/shm/vumeter', 'w') f.write(message + clear * ' ') @@ -556,6 +570,8 @@ def photobooth(beeps, camera, filmfolder, filmname, scene, shot, take, filename) #------------Remove----------------------- def remove(filmfolder, filmname, scene, shot, take, sceneshotortake): + foldername = filmfolder + filmname + '/' + 'scene' + str(scene).zfill(3) + '/shot' + str(shot).zfill(3) + '/' + filename = 'scene' + str(scene).zfill(3) + '_shot' + str(shot).zfill(3) + '_take' + str(take).zfill(3) pressed = '' buttonpressed = '' buttontime = time.time() @@ -565,6 +581,8 @@ def remove(filmfolder, filmname, scene, shot, take, sceneshotortake): menu = '', '' settings = 'YES', 'NO' selected = 0 + if os.path.exists(foldername + filename + '.h264') == False: + return scene, shot, take while True: writemenu(menu,settings,selected,header) pressed, buttonpressed, buttontime, holdbutton = getbutton(pressed, buttonpressed, buttontime, holdbutton) @@ -577,8 +595,6 @@ def remove(filmfolder, filmname, scene, shot, take, sceneshotortake): elif pressed == 'middle': if selected == 0: if sceneshotortake == 'take': - foldername = filmfolder + filmname + '/' + 'scene' + str(scene).zfill(3) + '/shot' + str(shot).zfill(3) + '/' - filename = 'scene' + str(scene).zfill(3) + '_shot' + str(shot).zfill(3) + '_take' + str(take).zfill(3) os.system('rm ' + foldername + filename + '.h264') os.system('rm ' + foldername + filename + '.mp4') os.system('rm ' + filmfolder + filmname + '/.thumbnails/' + filename + '.png') @@ -863,6 +879,8 @@ def copytousb(filmfolder, filmname): pressed, buttonpressed, buttontime, holdbutton = getbutton(pressed, buttonpressed, buttontime, holdbutton) usbconnected = os.path.ismount('/media/usb0') if pressed == 'middle': + writemessage('canceling..') + time.sleep(2) break time.sleep(0.02) if usbconnected == True: @@ -951,6 +969,12 @@ def getbutton(lastbutton, buttonpressed, buttontime, holdbutton): pressed = 'left' elif event == ord('d') or event == curses.KEY_RIGHT or readbus == 251: pressed = 'right' + elif event == ord('e') or readbus == 127: + pressed = 'record' + elif event == ord('c') or readbus == 253: + pressed = 'view' + elif event == ord('q') or readbus == 223: + pressed = 'delete' buttonpressed = True buttontime = time.time() holdbutton = pressed @@ -996,7 +1020,7 @@ def main(): call (['./startinterface.sh &'], shell = True) #MENUS - menu = 'MIDDLEBUTTON: ','SHUTTER:', 'ISO:', 'RED:', 'BLUE:', 'BRIGHT:', 'CONT:', 'SAT:', 'FLIP:', 'BEEP:', 'LENGTH:', 'MIC:', 'PHONES:', 'DSK:', '', 'SCENE:', 'SHOT:', 'TAKE', '', '' + menu = 'FILM:', 'SCENE:', 'SHOT:', 'TAKE:', '', 'SHUTTER:', 'ISO:', 'RED:', 'BLUE:', 'BRIGHT:', 'CONT:', 'SAT:', 'FLIP:', 'BEEP:', 'LENGTH:', 'MIC:', 'PHONES:', 'DSK:', 'COPY', 'UPLOAD', 'NEW', 'LOAD', 'UPDATE', 'MODE' actionmenu = 'Record', 'Play', 'Copy to USB', 'Upload', 'Update', 'New Film', 'Load Film', 'Remove', 'Photobooth' #STANDARD VALUES @@ -1015,7 +1039,6 @@ def main(): reclenght = 0 t = 0 rectime = '' - showrec = '' scene = 1 shot = 1 take = 1 @@ -1111,7 +1134,7 @@ def main(): backlight = True #RECORD AND PAUSE - elif pressed == 'middle' and selectedaction == 0 or reclenght != 0 and t > reclenght or t > 800: + elif pressed == 'record' or reclenght != 0 and t > reclenght or t > 800: foldername = filmfolder + filmname + '/' + 'scene' + str(scene).zfill(3) + '/shot' + str(shot).zfill(3) + '/' filename = 'scene' + str(scene).zfill(3) + '_shot' + str(shot).zfill(3) + '_take' + str(take).zfill(3) os.system('mkdir -p ' + foldername) @@ -1123,7 +1146,7 @@ def main(): #camera.led = True camera.start_recording(foldername + filename + '.h264', format='h264', quality=20) #camera.start_recording('/dev/shm/' + filename + '.h264', format='h264', quality=16) - os.system(tarinafolder + '/alsa-utils-1.0.25/aplay/arecord -f S16_LE -c 1 -r 44100 -vv /dev/shm/' + filename + '.wav &') + os.system(tarinafolder + '/alsa-utils-1.0.25/aplay/arecord -D hw:0 -f S16_LE -c 1 -r 44100 -vv /dev/shm/' + filename + '.wav &') starttime = time.time() #camera.wait_recording(10) elif recording == True: @@ -1135,7 +1158,6 @@ def main(): camera.stop_recording() t = 0 rectime = '' - showrec = '' vumetermessage('Tarina ' + tarinaversion[:-1] + ' ' + tarinavername[:-1]) thefile = foldername + filename #writemessage('Copying video file...') @@ -1174,7 +1196,7 @@ def main(): savesetting(camera.brightness, camera.contrast, camera.saturation, camera.shutter_speed, camera.iso, camera.awb_mode, camera.awb_gains, awb_lock, miclevel, headphoneslevel, filmfolder, filmname, scene, shot, take, thefile, beeps, flip, renderedshots) #PLAY - elif pressed == 'middle' and selectedaction == 1 and selected == 16 or pressed == 'middle' and selectedaction == 1 and selected == 17: + elif pressed == 'view' and menu[selected] == 'SHOT:' or pressed == 'view' and menu[selected] == 'TAKE:': if recording == False: takes = counttakes(filmname, filmfolder, scene, shot) if takes > 0: @@ -1191,7 +1213,7 @@ def main(): time.sleep(3) #VIEW SCENE - elif pressed == 'middle' and selectedaction == 1 and selected == 15: + elif pressed == 'view' and menu[selected] == 'SCENE:': if recording == False: filmfiles = renderlist(filmname, filmfolder, scene) renderfilename = filmfolder + filmname + '/scene' + str(scene).zfill(3) + '/scene' + str(scene).zfill(3) @@ -1199,7 +1221,7 @@ def main(): playthis(playfile, camera) #VIEW FILM - elif pressed == 'middle' and selectedaction == 1 and selected == 14: + elif pressed == 'view' and menu[selected] == 'FILM:': if recording == False: renderfullscene = True filmfiles = viewfilm(filmfolder, filmname) @@ -1208,7 +1230,7 @@ def main(): playthis(playfile, camera) #COPY TO USB - elif pressed == 'middle' and selectedaction == 2: + elif pressed == 'middle' and menu[selected] == 'COPY': if recording == False: copytousb(filmfolder, filmname) @@ -1239,7 +1261,7 @@ def main(): time.sleep(2) #UPLOAD - elif pressed == 'middle' and selectedaction == 3: + elif pressed == 'middle' and menu[selected] == 'UPLOAD': buttonpressed = time.time() if recording == False: renderfullscene = True @@ -1250,18 +1272,18 @@ def main(): selectedaction = 0 #LOAD FILM - elif pressed == 'middle' and selectedaction == 6: + elif pressed == 'middle' and menu[selected] == 'LOAD': camera.brightness, camera.contrast, camera.saturation, camera.shutter_speed, camera.iso, camera.awb_mode, camera.awb_gains, awb_lock, miclevel, headphoneslevel, filmfolder, filmname, scene, shot, take, thefile, beeps, flip, renderedshots = loadfilm(filmname,filmfolder) savesetting(camera.brightness, camera.contrast, camera.saturation, camera.shutter_speed, camera.iso, camera.awb_mode, camera.awb_gains, awb_lock, miclevel, headphoneslevel, filmfolder, filmname, scene, shot, take, thefile, beeps, flip, renderedshots) selectedaction = 0 #UPDATE - elif pressed == 'middle' and selectedaction == 4: + elif pressed == 'middle' and menu[selected] == 'UPDATE': tarinaversion, tarinavername = update(tarinaversion, tarinavername) selectedaction = 0 #NEW FILM - elif pressed == 'middle' and selectedaction == 5: + elif pressed == 'middle' and menu[selected] == 'NEW': if recording == False: scene = 1 shot = 1 @@ -1278,45 +1300,39 @@ def main(): #REMOVE #take - elif pressed == 'middle' and selected == 17 and selectedaction == 7: + elif pressed == 'delete' and menu[selected] == 'TAKE:': scene, shot, take = remove(filmfolder, filmname, scene, shot, take, 'take') savesetting(camera.brightness, camera.contrast, camera.saturation, camera.shutter_speed, camera.iso, camera.awb_mode, camera.awb_gains, awb_lock, miclevel, headphoneslevel, filmfolder, filmname, scene, shot, take, thefile, beeps, flip, renderedshots) time.sleep(0.2) #shot - elif pressed == 'middle' and selected == 16 and selectedaction == 7: + elif pressed == 'delete' and menu[selected] == 'SHOT:': scene, shot, take = remove(filmfolder, filmname, scene, shot, take, 'shot') savesetting(camera.brightness, camera.contrast, camera.saturation, camera.shutter_speed, camera.iso, camera.awb_mode, camera.awb_gains, awb_lock, miclevel, headphoneslevel, filmfolder, filmname, scene, shot, take, thefile, beeps, flip, renderedshots) time.sleep(0.2) #scene - elif pressed == 'middle' and selected == 15 and selectedaction == 7: + elif pressed == 'delete' and menu[selected] == 'SCENE:': scene, shot, take = remove(filmfolder, filmname, scene, shot, take, 'scene') savesetting(camera.brightness, camera.contrast, camera.saturation, camera.shutter_speed, camera.iso, camera.awb_mode, camera.awb_gains, awb_lock, miclevel, headphoneslevel, filmfolder, filmname, scene, shot, take, thefile, beeps, flip, renderedshots) time.sleep(0.2) #UP elif pressed == 'up': - if selected == 0: - if selectedaction < (len(actionmenu) - 1): - selectedaction = selectedaction + 1 - else: - selectedaction = 0 - time.sleep(0.05) - elif selected == 5: + if menu[selected] == 'BRIGHT:': camera.brightness = min(camera.brightness + 1, 99) - elif selected == 6: + elif menu[selected] == 'CONT:': camera.contrast = min(camera.contrast + 1, 99) - elif selected == 7: + elif menu[selected] == 'SAT:': camera.saturation = min(camera.saturation + 1, 99) - elif selected == 1: + elif menu[selected] == 'SHUTTER:': if camera.shutter_speed < 5000: camera.shutter_speed = min(camera.shutter_speed + 50, 50000) else: camera.shutter_speed = min(camera.shutter_speed + 210, 50000) - elif selected == 2: + elif menu[selected] == 'ISO:': camera.iso = min(camera.iso + 100, 1600) - elif selected == 9: + elif menu[selected] == 'BEEP:': beeps = beeps + 1 - elif selected == 8: + elif menu[selected] == 'FLIP:': if flip == 'yes': camera.hflip = False camera.vflip = False @@ -1327,10 +1343,10 @@ def main(): camera.vflip = True flip = 'yes' time.sleep(0.2) - elif selected == 10: + elif menu[selected] == 'LENGTH:': reclenght = reclenght + 1 time.sleep(0.1) - elif selected == 11: + elif menu[selected] == 'MIC:': if miclevel < 100: miclevel = miclevel + 2 #Wheezy @@ -1339,7 +1355,7 @@ def main(): #Jessie if debianversion == '8': os.system('amixer sset Mic ' + str(miclevel) + '%') - elif selected == 12: + elif menu[selected] == 'PHONES:': if headphoneslevel < 100: headphoneslevel = headphoneslevel + 2 #Wheezy @@ -1348,26 +1364,26 @@ def main(): #Jessie if debianversion == '8': os.system('amixer sset Playback ' + str(headphoneslevel) + '%') - elif selected == 15: + elif menu[selected] == 'SCENE:': scene, shot, take = browse2(filmname, filmfolder, scene, shot, take, 0, 1) removeimage(camera, overlay) imagename = filmfolder + filmname + '/.thumbnails/' + 'scene' + str(scene).zfill(3) + '_shot' + str(shot).zfill(3) + '_take' + str(take).zfill(3) + '.png' overlay = displayimage(camera, imagename) - elif selected == 16: + elif menu[selected] == 'SHOT:': scene, shot, take = browse2(filmname, filmfolder, scene, shot, take, 1, 1) removeimage(camera, overlay) imagename = filmfolder + filmname + '/.thumbnails/' + 'scene' + str(scene).zfill(3) + '_shot' + str(shot).zfill(3) + '_take' + str(take).zfill(3) + '.png' overlay = displayimage(camera, imagename) - elif selected == 17: + elif menu[selected] == 'TAKE:': scene, shot, take = browse2(filmname, filmfolder, scene, shot, take, 2, 1) removeimage(camera, overlay) imagename = filmfolder + filmname + '/.thumbnails/' + 'scene' + str(scene).zfill(3) + '_shot' + str(shot).zfill(3) + '_take' + str(take).zfill(3) + '.png' overlay = displayimage(camera, imagename) - elif selected == 3: + elif menu[selected] == 'RED:': camera.awb_mode = 'off' if float(camera.awb_gains[0]) < 7.98: camera.awb_gains = (float(camera.awb_gains[0]) + 0.02, float(camera.awb_gains[1])) - elif selected == 4: + elif menu[selected] == 'BLUE:': camera.awb_mode = 'off' if float(camera.awb_gains[1]) < 7.98: camera.awb_gains = (float(camera.awb_gains[0]), float(camera.awb_gains[1]) + 0.02) @@ -1377,33 +1393,29 @@ def main(): if selected > 0: selected = selected - 1 else: - selected = len(menu) - 3 + selected = len(menu) - 1 + if selected == 4: + selected = 3 #DOWN elif pressed == 'down': - if selected == 0: - if selectedaction > 0: - selectedaction = selectedaction - 1 - else: - selectedaction = len(actionmenu) - 1 - time.sleep(0.05) - elif selected == 5: + if menu[selected] == 'BRIGHT:': camera.brightness = max(camera.brightness - 1, 0) - elif selected == 6: + elif menu[selected] == 'CONT:': camera.contrast = max(camera.contrast - 1, -100) - elif selected == 7: + elif menu[selected] == 'SAT:': camera.saturation = max(camera.saturation - 1, -100) - elif selected == 1: + elif menu[selected] == 'SHUTTER:': if camera.shutter_speed < 5000: camera.shutter_speed = max(camera.shutter_speed - 50, 20) else: camera.shutter_speed = max(camera.shutter_speed - 200, 200) - elif selected == 2: + elif menu[selected] == 'ISO:': camera.iso = max(camera.iso - 100, 100) - elif selected == 9: + elif menu[selected] == 'BEEP:': if beeps > 0: beeps = beeps - 1 - elif selected == 8: + elif menu[selected] == 'FLIP:': if flip == 'yes': camera.hflip = False camera.vflip = False @@ -1414,11 +1426,11 @@ def main(): camera.vflip = True flip = 'yes' time.sleep(0.2) - elif selected == 10: + elif menu[selected] == 'LENGHT:': if reclenght > 0: reclenght = reclenght - 1 time.sleep(0.1) - elif selected == 11: + elif menu[selected] == 'MIC:': if miclevel > 0: miclevel = miclevel - 2 #Wheezy @@ -1427,7 +1439,7 @@ def main(): #Jessie if debianversion == '8': os.system('amixer sset Mic ' + str(miclevel) + '%') - elif selected == 12: + elif menu[selected] == 'PHONES:': if headphoneslevel > 0: headphoneslevel = headphoneslevel - 2 #Wheezy @@ -1436,41 +1448,42 @@ def main(): #Jessie if debianversion == '8': os.system('amixer sset Playback ' + str(headphoneslevel) + '%') - elif selected == 15: + elif menu[selected] == 'SCENE:': scene, shot, take = browse2(filmname, filmfolder, scene, shot, take, 0, -1) removeimage(camera, overlay) imagename = filmfolder + filmname + '/.thumbnails/' + 'scene' + str(scene).zfill(3) + '_shot' + str(shot).zfill(3) + '_take' + str(take).zfill(3) + '.png' overlay = displayimage(camera, imagename) - elif selected == 16: + elif menu[selected] == 'SHOT:': scene, shot, take = browse2(filmname, filmfolder, scene, shot, take, 1, -1) removeimage(camera, overlay) imagename = filmfolder + filmname + '/.thumbnails/' + 'scene' + str(scene).zfill(3) + '_shot' + str(shot).zfill(3) + '_take' + str(take).zfill(3) + '.png' overlay = displayimage(camera, imagename) - elif selected == 17: + elif menu[selected] == 'TAKE:': scene, shot, take = browse2(filmname, filmfolder, scene, shot, take, 2, -1) removeimage(camera, overlay) imagename = filmfolder + filmname + '/.thumbnails/' + 'scene' + str(scene).zfill(3) + '_shot' + str(shot).zfill(3) + '_take' + str(take).zfill(3) + '.png' overlay = displayimage(camera, imagename) - elif selected == 3: + elif menu[selected] == 'RED:': camera.awb_mode = 'off' if float(camera.awb_gains[0]) > 0.02: camera.awb_gains = (float(camera.awb_gains[0]) - 0.02, float(camera.awb_gains[1])) - elif selected == 4: + elif menu[selected] == 'BLUE:': camera.awb_mode = 'off' if float(camera.awb_gains[1]) > 0.02: camera.awb_gains = (float(camera.awb_gains[0]), float(camera.awb_gains[1]) - 0.02) #RIGHT elif pressed == 'right': - if selected < len(menu) - 3: + if selected < len(menu) - 1: selected = selected + 1 else: selected = 0 + if selected == 4: + selected = selected + 1 if recording == True: - showrec = 'RECLENGTH:' t = time.time() - starttime rectime = time.strftime("%H:%M:%S", time.gmtime(t)) - settings = actionmenu[selectedaction], str(camera.shutter_speed).zfill(5), str(camera.iso), str(float(camera.awb_gains[0]))[:4], str(float(camera.awb_gains[1]))[:4], str(camera.brightness), str(camera.contrast), str(camera.saturation), str(flip), str(beeps), str(reclenght), str(miclevel), str(headphoneslevel), diskleft, filmname, str(scene), str(shot), str(take), showrec, rectime + settings = filmname, str(scene), str(shot), str(take), rectime, str(camera.shutter_speed).zfill(5), str(camera.iso), str(float(camera.awb_gains[0]))[:4], str(float(camera.awb_gains[1]))[:4], str(camera.brightness), str(camera.contrast), str(camera.saturation), str(flip), str(beeps), str(reclenght), str(miclevel), str(headphoneslevel), diskleft, '', '', '', '', '', '' header='' #Check if menu is changed if pressed != '' or pressed != 'hold' or recording == True or rendermenu == True: diff --git a/vc/src/hello_pi/hello_interface/camerainterface.bin b/vc/src/hello_pi/hello_interface/camerainterface.bin Binary files differ. diff --git a/vc/src/hello_pi/hello_interface/main.c b/vc/src/hello_pi/hello_interface/main.c @@ -36,7 +36,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "bcm_host.h" #include "vgfont.h" -int32_t render_subtitle(GRAPHICS_RESOURCE_HANDLE img, const char *text, const uint32_t text_size, const uint32_t y_offset, uint32_t fontcolor) +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; @@ -45,44 +45,44 @@ int32_t render_subtitle(GRAPHICS_RESOURCE_HANDLE img, const char *text, const ui // 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, 0, y_offset-height, + graphics_resource_render_text_ext(img, x_offset, y_offset-height, GRAPHICS_RESOURCE_WIDTH, GRAPHICS_RESOURCE_HEIGHT, - GRAPHICS_RGBA32(100,150,150,0xff), /* fg */ + GRAPHICS_RGBA32(100,100,100,0xff), /* fg */ GRAPHICS_RGBA32(0,0,0,0xff), /* bg */ - text, 63, text_size); + text, 74, text_size); } if (fontcolor == 4) { - graphics_resource_render_text_ext(img, 11, y_offset-height, + graphics_resource_render_text_ext(img, x_offset, y_offset-height, GRAPHICS_RESOURCE_WIDTH, GRAPHICS_RESOURCE_HEIGHT, - GRAPHICS_RGBA32(100,150,150,0xff), /* fg */ + GRAPHICS_RGBA32(51,51,51,0xff), /* fg */ GRAPHICS_RGBA32(0,0,0,0xff), /* bg */ - text, 63, text_size); + text, 74, text_size); } if (fontcolor == 3) { - graphics_resource_render_text_ext(img, 0, y_offset-height, + graphics_resource_render_text_ext(img, x_offset, y_offset-height, GRAPHICS_RESOURCE_WIDTH, GRAPHICS_RESOURCE_HEIGHT, - GRAPHICS_RGBA32(100,150,150,0xff), /* fg */ + GRAPHICS_RGBA32(60,60,60,0xff), /* fg */ GRAPHICS_RGBA32(0,0,0,0xff), /* bg */ - text, 63, text_size); + text, 74, text_size); } if (fontcolor == 2) { - graphics_resource_render_text_ext(img, 0, y_offset-height, + graphics_resource_render_text_ext(img, x_offset, y_offset-height, GRAPHICS_RESOURCE_WIDTH, GRAPHICS_RESOURCE_HEIGHT, - GRAPHICS_RGBA32(100,150,150,0xff), /* fg */ + GRAPHICS_RGBA32(60,60,100,0xff), /* fg */ GRAPHICS_RGBA32(0,0,0,0xff), /* bg */ - text, 63, text_size); + text, 74, text_size); } if (fontcolor == 1) { - graphics_resource_render_text_ext(img, 0, y_offset-height, + 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(100,150,150,0xff), /* bg */ - text, 63, text_size); + GRAPHICS_RGBA32(255,255,255,0xff), /* fg */ + GRAPHICS_RGBA32(20,0,20,0xff), /* bg */ + text, 74, text_size); } return 0; } @@ -110,61 +110,337 @@ int main(void) graphics_display_resource(img, 0, LAYER, 0, 0, GRAPHICS_RESOURCE_WIDTH, GRAPHICS_RESOURCE_HEIGHT, VC_DISPMAN_ROT0, 1); uint32_t text_size = 20; - char text[63]; - char text2[63]; - char text3[63]; - char text4[63]; - char text5[63]; - char text6[63]; + 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; + char text[80]; + char text2[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]; 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(text, 63, fp) != NULL); + while(fgets(text, 74, fp) != NULL); fclose(fp); FILE *fp2; fp2 = fopen("/dev/shm/interface","r"); - fgets(text2, 62, fp2); - fgets(text3, 62, fp2); - fgets(text4, 62, fp2); - fgets(text5, 62, fp2); - fgets(text6, 62, fp2); + fgets(text2, 4, fp2); + selected = atoi(text2); + fgets(text2, 4, fp2); + len_string_header = atoi(text2) + 1; + fgets(header, len_string_header, fp2); + fgets(text2, 4, fp2); + len_string_film = atoi(text2) + 1; + fgets(film, len_string_film, fp2); + fgets(text2, 4, fp2); + len_string_scene = atoi(text2) + 1; + fgets(scene, len_string_scene, fp2); + fgets(text2, 4, fp2); + len_string_shot = atoi(text2) + 1; + fgets(shot, len_string_shot, fp2); + fgets(text2, 4, fp2); + len_string_take = atoi(text2) + 1; + fgets(take, len_string_take, fp2); + fgets(text2, 4, fp2); + len_string_rec = atoi(text2) + 1; + fgets(rec, len_string_rec, fp2); + fgets(text2, 4, fp2); + len_string_shutter = atoi(text2) + 1; + fgets(shutter, len_string_shutter, fp2); + fgets(text2, 4, fp2); + len_string_iso = atoi(text2) + 1; + fgets(iso, len_string_iso, fp2); + fgets(text2, 4, fp2); + len_string_red = atoi(text2) + 1; + fgets(red, len_string_red, fp2); + fgets(text2, 4, fp2); + len_string_blue = atoi(text2) + 1; + fgets(blue, len_string_blue, fp2); + fgets(text2, 4, fp2); + len_string_bright = atoi(text2) + 1; + fgets(bright, len_string_bright, fp2); + fgets(text2, 4, fp2); + len_string_cont = atoi(text2) + 1; + fgets(cont, len_string_cont, fp2); + fgets(text2, 4, fp2); + len_string_sat = atoi(text2) + 1; + fgets(sat, len_string_sat, fp2); + fgets(text2, 4, fp2); + len_string_flip = atoi(text2) + 1; + fgets(flip, len_string_flip, fp2); + fgets(text2, 4, fp2); + len_string_beep = atoi(text2) + 1; + fgets(beep, len_string_beep, fp2); + fgets(text2, 4, fp2); + len_string_lenght = atoi(text2) + 1; + fgets(lenght, len_string_lenght, fp2); + fgets(text2, 4, fp2); + len_string_mic = atoi(text2) + 1; + fgets(mic, len_string_mic, fp2); + fgets(text2, 4, fp2); + len_string_phones = atoi(text2) + 1; + fgets(phones, len_string_phones, fp2); + fgets(text2, 4, fp2); + len_string_dsk = atoi(text2) + 1; + fgets(dsk, len_string_dsk, fp2); + fgets(text2, 4, fp2); + len_string_more1 = atoi(text2) + 1; + fgets(more1, len_string_more1, fp2); + fgets(text2, 4, fp2); + len_string_more2 = atoi(text2) + 1; + fgets(more2, len_string_more2, fp2); + fgets(text2, 4, fp2); + len_string_more3 = atoi(text2) + 1; + fgets(more3, len_string_more3, fp2); + fgets(text2, 4, fp2); + len_string_more4 = atoi(text2) + 1; + fgets(more4, len_string_more4, fp2); + fgets(text2, 4, fp2); + len_string_more5 = atoi(text2) + 1; + fgets(more5, len_string_more5, fp2); + fgets(text2, 4, fp2); + len_string_more6 = atoi(text2) + 1; + fgets(more6, len_string_more6, fp2); + fgets(text2, 3, fp2); fclose(fp2); - //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_offset = 460; - uint32_t y_offset2 = 0; - uint32_t y_offset3 = 20; - uint32_t y_offset4 = 40; - uint32_t y_offset5 = 420; - uint32_t y_offset6 = 440; - // graphics_resource_fill(img, 0, 0, width, height, GRAPHICS_RGBA32(0,0,0,0x00)); - // blue, at the top (y=40) - - // draw the text if updated - render_subtitle(img, text, text_size, y_offset, 4); - render_subtitle(img, text2, text_size, y_offset2, 3); - render_subtitle(img, text3, text_size, y_offset3, 5); - render_subtitle(img, text4, text_size, y_offset4, 2); - if(text5[1] == ' ' ) { - render_subtitle(img, text5, text_size, y_offset5, 2); - render_subtitle(img, text6, text_size, y_offset6, 2); - } - if(text5[1] != ' ' ) { - render_subtitle(img, text5, text_size, y_offset5, 2); - render_subtitle(img, text6, text_size, y_offset6, 1); + if (text2[0] == 'E' && text2[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_offset = 460; + uint32_t y_offset2 = 0; + uint32_t y_offset3 = 22; + uint32_t y_offset4 = 44; + uint32_t y_offset5 = 418; + uint32_t y_offset6 = 440; + 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 = 15; + int color; + int count; + char seleold; + if (seleold != selected){ + count = 0; + } + seleold = selected; + if (count < 200){ + count = count + 1; + } + if (count < 100){ + color = 5; + } + else{ + color = 4; + } + // draw the text if updated + render_subtitle(img, text, text_size, 0, y_offset, 4); + if(strlen(header) != 0) { + render_subtitle(img, header, text_size, 0, y_offset2, 5); + render_subtitle(img, film, text_size, 0, y_offset3, 5); + render_subtitle(img, scene, text_size, len_string_film * 12, y_offset3, 5); + render_subtitle(img, shot, text_size, len_string_film * 12 + len_string_scene * 12, y_offset3, 5); + render_subtitle(img, take, text_size, len_string_film * 12 + len_string_scene * 12 + len_string_shot * 12, y_offset3, 5); + } + if(strlen(header) == 0) { + render_subtitle(img, rec, text_size, 700, y_offset5, 2); + 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); + } } graphics_update_displayed_resource(img, 0, 0, 0, 0); - usleep(100000); + } + usleep(50000); } 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/vc/src/hello_pi/hello_interface/mainold.c b/vc/src/hello_pi/hello_interface/mainold.c @@ -0,0 +1,170 @@ +/* +Copyright (c) 2012, Broadcom Europe Ltd +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the copyright holder nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +// Test app for VG font library. + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <assert.h> +#include <unistd.h> + +#include "bcm_host.h" +#include "vgfont.h" + +int32_t render_subtitle(GRAPHICS_RESOURCE_HANDLE img, const char *text, const uint32_t text_size, const uint32_t y_offset, uint32_t fontcolor) +{ + uint32_t height=0; + uint32_t 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, 0, y_offset-height, + GRAPHICS_RESOURCE_WIDTH, + GRAPHICS_RESOURCE_HEIGHT, + GRAPHICS_RGBA32(100,150,150,0xff), /* fg */ + GRAPHICS_RGBA32(0,0,0,0xff), /* bg */ + text, 74, text_size); + } + if (fontcolor == 4) { + graphics_resource_render_text_ext(img, 11, y_offset-height, + GRAPHICS_RESOURCE_WIDTH, + GRAPHICS_RESOURCE_HEIGHT, + GRAPHICS_RGBA32(100,150,150,0xff), /* fg */ + GRAPHICS_RGBA32(0,0,0,0xff), /* bg */ + text, 74, text_size); + } + if (fontcolor == 3) { + graphics_resource_render_text_ext(img, 0, y_offset-height, + GRAPHICS_RESOURCE_WIDTH, + GRAPHICS_RESOURCE_HEIGHT, + GRAPHICS_RGBA32(100,150,150,0xff), /* fg */ + GRAPHICS_RGBA32(0,0,0,0xff), /* bg */ + text, 74, text_size); + } + if (fontcolor == 2) { + graphics_resource_render_text_ext(img, 0, y_offset-height, + GRAPHICS_RESOURCE_WIDTH, + GRAPHICS_RESOURCE_HEIGHT, + GRAPHICS_RGBA32(100,150,150,0xff), /* fg */ + GRAPHICS_RGBA32(0,0,0,0xff), /* bg */ + text, 74, text_size); + } + if (fontcolor == 1) { + graphics_resource_render_text_ext(img, 0, y_offset-height, + GRAPHICS_RESOURCE_WIDTH, + GRAPHICS_RESOURCE_HEIGHT, + GRAPHICS_RGBA32(0,0,0,0xff), /* fg */ + GRAPHICS_RGBA32(100,150,150,0xff), /* bg */ + text, 74, text_size); + } + 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 = 20; + char text[74]; + char text2[74]; + char text3[74]; + char text4[74]; + char text5[74]; + char text6[74]; + 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(text, 74, fp) != NULL); + fclose(fp); + FILE *fp2; + fp2 = fopen("/dev/shm/interface","r"); + fgets(text2, 73, fp2); + fgets(text3, 73, fp2); + fgets(text4, 73, fp2); + fgets(text5, 73, fp2); + fgets(text6, 73, fp2); + fclose(fp2); + //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_offset = 460; + uint32_t y_offset2 = 0; + uint32_t y_offset3 = 20; + uint32_t y_offset4 = 40; + uint32_t y_offset5 = 420; + uint32_t y_offset6 = 440; + // graphics_resource_fill(img, 0, 0, width, height, GRAPHICS_RGBA32(0,0,0,0x00)); + // blue, at the top (y=40) + + // draw the text if updated + render_subtitle(img, text, text_size, y_offset, 4); + render_subtitle(img, text2, text_size, y_offset2, 3); + render_subtitle(img, text3, text_size, y_offset3, 5); + render_subtitle(img, text4, text_size, y_offset4, 2); + if(text5[1] == ' ' ) { + render_subtitle(img, text5, text_size, y_offset5, 2); + render_subtitle(img, text6, text_size, y_offset6, 2); + } + if(text5[1] != ' ' ) { + render_subtitle(img, text5, text_size, y_offset5, 2); + render_subtitle(img, text6, text_size, y_offset6, 1); + } + graphics_update_displayed_resource(img, 0, 0, 0, 0); + usleep(100000); + } + + graphics_display_resource(img, 0, LAYER, 0, 0, GRAPHICS_RESOURCE_WIDTH, GRAPHICS_RESOURCE_HEIGHT, VC_DISPMAN_ROT0, 0); + graphics_delete_resource(img); + + return 0; +} +