commit fae6cac022521599c420b147b7d4e4c16d55fbc1
parent e6b228fce313fd5f0c50bd4bbc44afcaa6b6c016
Author: rbckman <rob@tarina.org>
Date: Thu, 9 Nov 2023 21:05:24 +0000
HDMI output working! now able to change filmfolder
Diffstat:
4 files changed, 227 insertions(+), 96 deletions(-)
diff --git a/VERSION b/VERSION
@@ -1,2 +1,2 @@
-1.40
+1.41
Jackson
diff --git a/gui/src/main.c b/gui/src/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 x_offset, 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 text_size_selected, const uint32_t x_offset, const uint32_t y_offset, uint32_t fontcolor)
{
uint32_t height=0;
uint32_t img_w, img_h;
@@ -98,7 +98,7 @@ int32_t render_subtitle(GRAPHICS_RESOURCE_HANDLE img, const char *text, const ui
GRAPHICS_RESOURCE_HEIGHT,
GRAPHICS_RGBA32(0,0,0,0xff), /* fg */
GRAPHICS_RGBA32(30,255,255,0xff), /* bg */
- text, 90, 16);
+ text, 90, text_size_selected);
}
return 0;
}
@@ -126,6 +126,7 @@ 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 = 15;
+ uint32_t text_size_selected = 16;
FILE * fp;
FILE * fp2;
FILE * fp3;
@@ -141,6 +142,38 @@ int main(void)
char newread[500];
char oldread[500];
char vumeter[130];
+ 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;
+ uint32_t y_offset = 466;
+ int space = 10;
+ int morespace = 12;
+ int rectime = 700;
+ int color = 3;
+ int row1 = 0;
+ int row2 = 0;
+ int row3 = 0;
+ int row4 = 0;
+ int row5 = 0;
+ if (width == 1920){
+ y_offset2 = 5;
+ y_offset3 = 45;
+ y_offset4 = 85;
+ y_offset5 = 960;
+ y_offset6 = 1000;
+ y_offset = 1040;
+ rectime = 1600;
+ text_size = 30;
+ text_size_selected = 32;
+ space = 23;
+ morespace = 27;
+ }
+ else {
+ space = 10;
+ morespace = 12;
+ }
while (1) {
// char ch;
linenr = 0;
@@ -156,22 +189,16 @@ int main(void)
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;
+ color = 3;
+ row1 = 0;
+ row2 = 0;
+ row3 = 0;
+ row4 = 0;
+ row5 = 0;
graphics_resource_fill(img, 0, 0, width, height, GRAPHICS_RGBA32(0,0,0,0x00));
// blue, at the top (y=40)
// selected 0 1 2 3 4 5 6 7 8
- int space = 10;
- int morespace = 12;
- int color = 3;
- int row1 = 0;
- int row2 = 0;
- int row3 = 0;
- int row4 = 0;
- int row5 = 0;
+
// draw the text if updated
fp2 = fopen("/dev/shm/interface", "r");
if (fp2 != NULL){
@@ -201,46 +228,46 @@ int main(void)
header = 1;
if (selected == 420){
if (linenr == 1)
- render_subtitle(img, line, text_size, 0, y_offset2, 5);
+ render_subtitle(img, line, text_size, text_size_selected, 0, y_offset2, 5);
if (linenr > 1) {
- render_subtitle(img, line, text_size, row1, y_offset3, 5);
+ render_subtitle(img, line, text_size, text_size_selected, row1, y_offset3, 5);
row1 += read * space + morespace;
}
}
if (header == 0){ //check if normal menu or header menu
if (selected < 420){
if ((linenr == 6+menuadd) && (read > 0)){ //show recording time if there is any
- render_subtitle(img, line, text_size, 700, y_offset2, 3);
+ render_subtitle(img, line, text_size, text_size_selected, rectime, y_offset2, 3);
}
if (linenr >= 2+menuadd && linenr <= 5+menuadd){
if (color == 6)
color = 5;
- render_subtitle(img, line, text_size, row1, y_offset2, color);
+ render_subtitle(img, line, text_size, text_size_selected, row1, y_offset2, color);
row1 += read * space + morespace;
}
if (linenr >= 7+menuadd && linenr <= 12+menuadd){
- render_subtitle(img, line, text_size, row2, y_offset3, color);
+ render_subtitle(img, line, text_size, text_size_selected, row2, y_offset3, color);
row2 += read * space + morespace;
}
if (linenr >= 13+menuadd && linenr <= 20+menuadd){
- render_subtitle(img, line, text_size, row3, y_offset4, color);
+ render_subtitle(img, line, text_size, text_size_selected, row3, y_offset4, color);
row3 += read * space + morespace;
}
if (linenr >= 21+menuadd && linenr <= 27+menuadd){
- render_subtitle(img, line, text_size, row4, y_offset5, color);
+ render_subtitle(img, line, text_size, text_size_selected, row4, y_offset5, color);
row4 += read * space + morespace;
}
if (linenr >= 28+menuadd && linenr <= 40+menuadd){
- render_subtitle(img, line, text_size, row5, y_offset6, color);
+ render_subtitle(img, line, text_size, text_size_selected, row5, y_offset6, color);
row5 += read * space + morespace;
}
}
}
else { // header menu
if (linenr == 1+menuadd)
- render_subtitle(img, line, text_size, 0, y_offset2, 5);
+ render_subtitle(img, line, text_size, text_size_selected, 0, y_offset2, 5);
if (linenr > 1+menuadd){
- render_subtitle(img, line, text_size, row1, y_offset3, color);
+ render_subtitle(img, line, text_size, text_size_selected, row1, y_offset3, color);
row1 += read * space + morespace;
}
}
@@ -254,7 +281,6 @@ int main(void)
}
//graphics_update_displayed_resource(img, 0, 0, 0, 0);
}
- uint32_t y_offset = 466;
char s_vol1 = vumeter[85];
char s_vol2 = vumeter[86];
char s_vol[1];
@@ -269,7 +295,7 @@ int main(void)
vucolor = 2;
if (vol >= 99)
vucolor = 3;
- render_subtitle(img, vumeter, text_size, 0, y_offset, vucolor);
+ render_subtitle(img, vumeter, text_size, text_size_selected , 0, y_offset, vucolor);
graphics_update_displayed_resource(img, 0, 0, 0, 0);
usleep(20000);
}
diff --git a/gui/tarinagui.bin b/gui/tarinagui.bin
Binary files differ.
diff --git a/tarina.py b/tarina.py
@@ -48,7 +48,7 @@ print('running debian ' + debianversion)
#I2CBUTTONS
probei2c = 0
-while probei2c < 10:
+while probei2c < 3:
try:
if debianversion == "stretch":
os.system('sudo modprobe i2c-dev')
@@ -76,18 +76,17 @@ while probei2c < 10:
i2cbuttons = False
probei2c += 1
time.sleep(1)
+ bus=''
#MAIN
def main():
- global headphoneslevel, miclevel, tarinafolder, screen, loadfilmsettings, plughw, channels, filmfolder, scene, showmenu, rendermenu, quality, profilelevel, i2cbuttons, menudone, soundrate, soundformat, process, serverstate, que, port, recording, onlysound, camera_model, fps_selection, fps_selected, fps, db, selected, cammode, newfilmname, camera_recording
+ global headphoneslevel, miclevel, tarinafolder, screen, loadfilmsettings, plughw, channels, filmfolder, scene, showmenu, rendermenu, quality, profilelevel, i2cbuttons, menudone, soundrate, soundformat, process, serverstate, que, port, recording, onlysound, camera_model, fps_selection, fps_selected, fps, db, selected, cammode, newfilmname, camera_recording, abc
# Get path of the current dir, then use it as working directory:
rundir = os.path.dirname(__file__)
if rundir != '':
os.chdir(rundir)
- filmfolder = "/home/pi/Videos/"
- picfolder = "/home/pi/Pictures/"
- if os.path.isdir(filmfolder) == False:
- os.makedirs(filmfolder)
+ #filmfolder = "/home/pi/Videos/"
+ #picfolder = "/home/pi/Pictures/"
tarinafolder = os.getcwd()
#MENUS
@@ -171,9 +170,15 @@ def main():
tarinavername = f.readline()
db=''
+ #FIRE UP CAMERA
+ camera = startcamera(lens,fps)
+ #GET FILMFOLDER AND CAMERA VERSION
+ camera_model, camera_revision , filmfolder = getconfig(camera)
+ if os.path.isdir(filmfolder) == False:
+ os.makedirs(filmfolder)
#SYSTEM CONFIGS (turn off hdmi)
- run_command('tvservice -o')
+ #run_command('tvservice -o')
#Kernel page cache optimization for sd card
run_command('sudo ' + tarinafolder + '/extras/sdcardhack.sh')
#Make screen shut off work and run full brightness
@@ -184,7 +189,6 @@ def main():
diskleft = str(int(disk.f_bavail * disk.f_frsize / 1024 / 1024 / 1024)) + 'Gb'
#START INTERFACE
startinterface()
- camera = startcamera(lens,fps)
#LOAD FILM AND SCENE SETTINGS
try:
@@ -249,7 +253,7 @@ def main():
serverstate_old='off'
wifistate_old='off'
- camera_model, camera_revision = getconfig(camera)
+ camera_model, camera_revision, filmfolder= getconfig(camera)
#--------------MAIN LOOP---------------#
while True:
@@ -257,8 +261,6 @@ def main():
if pressagain != '':
pressed = pressagain
pressagain = ''
- if buttonpressed == True:
- flushbutton()
#event = screen.getch()
if wifistate != wifistate_old:
if wifistate == 'on':
@@ -694,18 +696,18 @@ def main():
shot=1
take=1
#HELPME
- elif event == 'H':
- if webz_on() == True:
- writemessage('Rob resolving the error now...')
- try:
- stopinterface(camera)
- run_command('reset')
- run_command('ssh -R 18888:localhost:22 tarina@tarina.org -p 13337')
- startinterface()
- camera = startcamera(lens,fps)
- loadfilmsettings = True
- except:
- writemessage('sry! no rob help installed')
+ #elif event == 'H':
+ # if webz_on() == True:
+ # writemessage('Rob resolving the error now...')
+ # try:
+ # stopinterface(camera)
+ # run_command('reset')
+ # run_command('ssh -R 18888:localhost:22 tarina@tarina.org -p 13337')
+ # startinterface()
+ # camera = startcamera(lens,fps)
+ # loadfilmsettings = True
+ # except:
+ # writemessage('sry! no rob help installed')
#DEVELOP
elif event == 'D':
try:
@@ -717,17 +719,17 @@ def main():
except:
writemessage('hmm.. couldnt enter developer mode')
#PICTURE
- elif event == 'J':
- try:
- stopinterface(camera)
- run_command('raspistill -ISO 800 -ss 6000000 -o '+picfolder+'test'+str(pic).zfill(3)+'.jpeg')
- pic = pic + 1
- #os.system('scp '+picfolder/+'test.jpeg user@10.42.0.1:~/pic.jpeg')
- startinterface()
- camera = startcamera(lens,fps)
- loadfilmsetings = True
- except:
- writemessage('hmm.. couldnt enter developer mode')
+ #elif event == 'J':
+ # try:
+ # stopinterface(camera)
+ # run_command('raspistill -ISO 800 -ss 6000000 -o '+picfolder+'test'+str(pic).zfill(3)+'.jpeg')
+ # pic = pic + 1
+ # #os.system('scp '+picfolder/+'test.jpeg user@10.42.0.1:~/pic.jpeg')
+ # startinterface()
+ # camera = startcamera(lens,fps)
+ # loadfilmsetings = True
+ # except:
+ # writemessage('hmm.. couldnt enter developer mode')
elif pressed == 'screen':
if backlight == False:
# requires wiringpi installed
@@ -1099,17 +1101,17 @@ def main():
#RECORD AND PAUSE
if beepcountdown > 1:
if time.time() - lastbeep > 1:
- beep()
+ beep(bus)
beepcountdown -= 1
lastbeep = time.time()
logger.info('beepcountdown: ' + str(beepcountdown))
vumetermessage('Filming in ' + str(beepcountdown) + ' seconds, press record again to cancel ')
elif beepcountdown > 0:
if time.time() - float(lastbeep) > 0.1:
- beep()
+ beep(bus)
vumetermessage('Get ready!!')
if time.time() - lastbeep > 1:
- longbeep()
+ longbeep(bus)
beepcountdown = 0
pressed = 'record'
print('exhausted from all beepings')
@@ -1193,12 +1195,14 @@ def main():
onlysound = False
scenes, shots, takes = browse(filmname,filmfolder,scene,shot,take)
if beeps > 0:
- buzz(300)
+ if bus:
+ buzz(300)
if round(fps) != 25:
compileshot(foldername + filename,filmfolder,filmname)
#os.system('cp /dev/shm/' + filename + '.wav ' + foldername + filename + '.wav')
if beeps > 0:
- buzz(150)
+ if bus:
+ buzz(150)
t = 0
rectime = ''
vumetermessage('Tarina ' + tarinaversion[:-1] + ' ' + tarinavername[:-1])
@@ -2252,6 +2256,7 @@ def getfilms(filmfolder):
#-------------Load tarina config---------------
def getconfig(camera):
+ filmfolder=''
version = camera.revision
home = os.path.expanduser('~')
configfile = home + '/.tarina/config.ini'
@@ -2260,16 +2265,31 @@ def getconfig(camera):
os.makedirs(configdir)
config = configparser.ConfigParser()
if config.read(configfile):
- camera_model = config['SENSOR']['model']
- camera_revision = config['SENSOR']['revision']
- if camera_model == version:
- return camera_model, camera_revision
- elif version == 'imx219':
+ try:
+ camera_model = config['SENSOR']['model']
+ except:
+ logger.info("couldnt read config")
+ try:
+ camera_revision = config['SENSOR']['revision']
+ except:
+ logger.info("couldnt read config")
+ try:
+ filmfolder = config['USER']['filmfolder']
+ return camera_model, camera_revision, filmfolder+'/'
+ except:
+ logger.info("couldnt read config")
+ if version == 'imx219':
+ config['SENSOR'] = {}
config['SENSOR']['model'] = version
config['SENSOR']['revision'] = 'standard'
with open(configfile, 'w') as f:
config.write(f)
- return version, camera_revision
+ elif version == 'imx477':
+ config['SENSOR'] = {}
+ config['SENSOR']['model'] = version
+ config['SENSOR']['revision'] = 'hq-camera'
+ with open(configfile, 'w') as f:
+ config.write(f)
else:
pressed = ''
buttonpressed = ''
@@ -2296,9 +2316,18 @@ def getconfig(camera):
config['SENSOR']['revision'] = camera_revision
with open(configfile, 'w') as f:
config.write(f)
- return camera_model, camera_revision
time.sleep(0.02)
+ if filmfolder != '':
+ return version, camera_revision, filmfolder+'/'
+ else:
+ filmfolder = namesomething('Your film folder: ', home+'/Videos')
+ config['USER'] = {}
+ config['USER']['filmfolder'] = filmfolder
+ with open(configfile, 'w') as f:
+ config.write(f)
+ return camera_model, camera_revision, filmfolder+'/'
+
#-------------Calc folder size with du-----------
def du(path):
@@ -2375,6 +2404,70 @@ def loadfilm(filmname, filmfolder):
return filmname
time.sleep(0.02)
+
+#---------Name anything really-----------
+
+def namesomething(what, readymadeinput):
+ global abc
+ anything = readymadeinput
+ pressed = ''
+ buttonpressed = ''
+ buttontime = time.time()
+ holdbutton = ''
+ abcx = 0
+ helpmessage = 'Up, Down (select characters) Right (next). Middle (done)'
+ cursor = '_'
+ blinking = True
+ pausetime = time.time()
+ while True:
+ message = what + anything
+ print(term.clear+term.home)
+ print(message+cursor)
+ writemessage(message + cursor)
+ vumetermessage(helpmessage)
+ pressed, buttonpressed, buttontime, holdbutton, event, keydelay = getbutton(pressed, buttonpressed, buttontime, holdbutton)
+ if event == ' ':
+ event = '_'
+ if pressed == 'down':
+ pausetime = time.time()
+ if abcx < (len(abc) - 1):
+ abcx = abcx + 1
+ cursor = abc[abcx]
+ elif pressed == 'up':
+ pausetime = time.time()
+ if abcx > 0:
+ abcx = abcx - 1
+ cursor = abc[abcx]
+ elif pressed == 'right':
+ pausetime = time.time()
+ if len(anything) < 30:
+ anything = anything + abc[abcx]
+ cursor = abc[abcx]
+ else:
+ helpmessage = 'Yo, maximum characters reached bro!'
+ elif pressed == 'left' or pressed == 'remove':
+ pausetime = time.time()
+ if len(anything) > 0:
+ anything = anything[:-1]
+ cursor = abc[abcx]
+ elif pressed == 'middle' or event == 10:
+ if len(anything) > 0:
+ if abc[abcx] != '_':
+ anything = anything + abc[abcx]
+ return anything
+ elif event in abc:
+ pausetime = time.time()
+ anything = anything + event
+ if time.time() - pausetime > 0.5:
+ if blinking == True:
+ cursor = abc[abcx]
+ if blinking == False:
+ cursor = ' '
+ blinking = not blinking
+ pausetime = time.time()
+ time.sleep(keydelay)
+
+
#-------------New film----------------
def nameyourfilm(filmfolder, filmname, abc, newfilm):
@@ -2387,6 +2480,7 @@ def nameyourfilm(filmfolder, filmname, abc, newfilm):
holdbutton = ''
abcx = 0
helpmessage = 'Up, Down (select characters) Right (next). Middle (done), Retake (Cancel)'
+ vumetermessage('Press enter if you want to leave it untitled')
cursor = '_'
blinking = True
pausetime = time.time()
@@ -2580,7 +2674,8 @@ def timelapse(beeps,camera,filmname,foldername,filename,between,duration,backlig
vumetermessage('Timelapse lenght is now ' + str(round(n * duration,2)) + ' second clip ')
if recording == False and t > between:
if beeps > 0:
- buzz(150)
+ if bus:
+ buzz(150)
#camera.start_recording(foldername + 'timelapse/' + filename + '_' + str(n).zfill(3) + '.h264', format='h264', quality=26, bitrate=5000000)
camera.start_recording(foldername + 'timelapse/' + filename + '_' + str(n).zfill(3) + '.h264', format='h264', quality=quality, level=profilelevel)
if sound == True:
@@ -4320,26 +4415,28 @@ def stopstream(camera, stream):
#-------------Beeps-------------------
-def beep():
- buzzerrepetitions = 100
- buzzerdelay = 0.00001
- for _ in range(buzzerrepetitions):
- for value in [0xC, 0x4]:
- #GPIO.output(1, value)
- bus.write_byte_data(DEVICE,OLATA,value)
- time.sleep(buzzerdelay)
+def beep(bus):
+ if bus:
+ buzzerrepetitions = 100
+ buzzerdelay = 0.00001
+ for _ in range(buzzerrepetitions):
+ for value in [0xC, 0x4]:
+ #GPIO.output(1, value)
+ bus.write_byte_data(DEVICE,OLATA,value)
+ time.sleep(buzzerdelay)
return
-def longbeep():
- buzzerrepetitions = 100
- buzzerdelay = 0.0001
- for _ in range(buzzerrepetitions * 5):
- for value in [0xC, 0x4]:
- #GPIO.output(1, value)
- bus.write_byte_data(DEVICE,OLATA,value)
- buzzerdelay = buzzerdelay - 0.00000004
- time.sleep(buzzerdelay)
- bus.write_byte_data(DEVICE,OLATA,0x4)
+def longbeep(bus):
+ if bus:
+ buzzerrepetitions = 100
+ buzzerdelay = 0.0001
+ for _ in range(buzzerrepetitions * 5):
+ for value in [0xC, 0x4]:
+ #GPIO.output(1, value)
+ bus.write_byte_data(DEVICE,OLATA,value)
+ buzzerdelay = buzzerdelay - 0.00000004
+ time.sleep(buzzerdelay)
+ bus.write_byte_data(DEVICE,OLATA,0x4)
return
def buzz(buzzerlenght):
@@ -4517,15 +4614,19 @@ def getbutton(lastbutton, buttonpressed, buttontime, holdbutton):
pressed=nextstatus
#print(nextstatus)
except:
- print('process not found')
+ #print('process not found')
+ pass
+
with term.cbreak():
val = term.inkey(timeout=0)
if val.is_sequence:
event = val.name
#print(event)
+ flushbutton()
elif val:
event = val
#print(event)
+ flushbutton()
else:
event = ''
keydelay = 0.08
@@ -4566,9 +4667,11 @@ def getbutton(lastbutton, buttonpressed, buttontime, holdbutton):
pressed = 'view'
elif event == 'KEY_DELETE' or (readbus == 223 and readbus2 == 247):
pressed = 'remove'
+ elif event == 'KEY_BACKSPACE':
+ pressed = 'remove'
elif event == 'E' or (readbus2 == 245 and readbus == 191):
pressed = 'peak'
- elif (readbus2 == 245 and readbus == 223):
+ elif event == 'S' or (readbus2 == 245 and readbus == 223):
pressed = 'screen'
elif event == 'A' or (readbus2 == 245 and readbus == 127):
pressed = 'showmenu'
@@ -4634,7 +4737,9 @@ def startcamera(lens, fps):
#
#camera frame rate sync to audio clock
#
- camera_model, camera_revision = getconfig(camera)
+ camera_model, camera_revision , filmfolder = getconfig(camera)
+ if os.path.isdir(filmfolder) == False:
+ os.makedirs(filmfolder)
# v1 = 'ov5647'
# v2 = ?
logger.info("picamera version is: " + camera_model + ' ' + camera_revision)