11-04-2012, 02:14 PM | #31 |
Addict
Posts: 348
Karma: 209937
Join Date: Jan 2012
Location: Virginia, US
Device: Kobo Wifi, Kobo Glo
|
Sorry about the permission denied, I forgot to set it as public.
I really don't know why it can't load the font file. I'm looking into it. Does it work if you change the font-loading lines in weather.py to use a default font? Code:
tiny_font = pygame.font.Font(None, 18) small_font = pygame.font.Font(None, 22) font = pygame.font.Font(None, 40) comfortaa = pygame.font.Font(None, 60) comfortaa_small = pygame.font.Font(None, 35) Last edited by KevinShort; 11-04-2012 at 02:19 PM. |
11-04-2012, 02:42 PM | #32 | |
Avid reader
Posts: 872
Karma: 6399168
Join Date: Apr 2009
Location: UK
Device: Samsung Galaxy Z Flip 4 / Kindle Paperwhite / TCL Nxtpaper 14
|
Quote:
I lied in my last post, I can't leave anything alone until it's working... It looks like it can't load the TrueType fonts. When I converted them to otf format and used those instead it worked. Then I just had to copy full_update from .python into the weather app folder (or change line 363 in the weather.py script to point to it) and it worked perfectly! Presumably full_update looks in the current directory for a file called image.png and blats it to the display? Thanks ever so much for this. Now I've got it working I'm going to make an astronomer's version, possibly based on data from 7timer.com. I can't quite believe that the Kobo can run Python and pygame natively - that is so cool! Andrew |
|
Advert | |
|
11-04-2012, 03:04 PM | #33 |
Addict
Posts: 348
Karma: 209937
Join Date: Jan 2012
Location: Virginia, US
Device: Kobo Wifi, Kobo Glo
|
Great! Yeah, I misplaced full_update. It was supposed to be in the same directory as weather.py.
And that's weird that TTF files don't work... Pygame is actually drawing directly to the Kobo's framebuffer, full_update just tells the system to update the e-ink display. Edit: I've updated the Kobo Touch installer to use OTF fonts, as well as placed full_update where it needs to be. Last edited by KevinShort; 12-15-2012 at 10:10 AM. |
11-04-2012, 08:52 PM | #34 |
Junior Member
Posts: 2
Karma: 10
Join Date: Nov 2012
Device: kobo wifi
|
Fantastic work, I was able to get the weather display working on my kobo wifi easily! I''m now working on making it display some custom data of my own. How did you edit the python file during development? vi is such a pain to use, is there some easy way to get nano (or similar) running on the device?
|
11-04-2012, 09:18 PM | #35 |
Grand Sorcerer
Posts: 12,892
Karma: 76440364
Join Date: Nov 2007
Location: Toronto
Device: Libra H2O, Libra Colour
|
It could be worse... could be emacs rather than vi, or teco (but not sure teco ever got ported from DEC).
|
Advert | |
|
11-05-2012, 09:17 AM | #36 |
Member
Posts: 17
Karma: 11628
Join Date: Oct 2012
Device: Kobo Touch
|
Would it be possible to make the home button restart the Kobo? This way, I can add a link in ikarus9999's plugin to the weather-app, make it kill nickel and run, and still be able to "get back" to nickel by restarting the device using the home button. It's kind of a hassle that you have to telnet into the device to reboot it now.
|
11-05-2012, 10:13 AM | #37 | ||
Addict
Posts: 348
Karma: 209937
Join Date: Jan 2012
Location: Virginia, US
Device: Kobo Wifi, Kobo Glo
|
Quote:
on my Wifi. But if you'd still like to have nano on your Kobo, you could try downloading and extracting this debian package to your Wifi. Quote:
the weather display by pressing the back and home keys at the same time. The easiest way to do this would probably be to start a "listener" script when you start the weather display. Here's a python script that waits for the home button to be pressed and then restarts the device: Code:
import struct from subprocess import call buttons = open("/dev/input/event0") format = "iihhi" key_event = buttons.read(16) running = 1 while running: (key_time1, key_time2, key_type, key_code, key_value) = struct.unpack(format, key_event) # Home button. if key_code == 102: if key_value == 1: print "Home button pressed" # Restart the device. call(["/bin/busybox", "reboot"]) key_event = buttons.read(16) weather display: Code:
#!/bin/sh killall nickel cd /mnt/onboard/.apps/koboWeather python listener.py & ./autoupdate.sh python weather.py Last edited by KevinShort; 11-05-2012 at 12:37 PM. Reason: updated script |
||
11-05-2012, 12:55 PM | #38 | |
Avid reader
Posts: 872
Karma: 6399168
Join Date: Apr 2009
Location: UK
Device: Samsung Galaxy Z Flip 4 / Kindle Paperwhite / TCL Nxtpaper 14
|
Quote:
Code:
def display(days, highs, lows, conditions, img_links, unit): print("Creating image . . .") #### change for windows + python 2.6 if (platform.system() == 'Windows'): pygame.init() else: pygame.display.init() ### pygame.font.init() pygame.mouse.set_visible(False) white = (255, 255, 255) black = (0, 0, 0) gray = (125, 125, 125) #### change for windows ### if (platform.system() == 'Windows'): display = pygame.display.set_mode((600, 800)) else: display = pygame.display.set_mode((800, 600), pygame.FULLSCREEN) ### screen = pygame.Surface((600, 800)) screen.fill(white) tiny_font = pygame.font.Font("Cabin-Regular.otf", 18) small_font = pygame.font.Font("Fabrica.otf", 22) font = pygame.font.Font("Forum-Regular.otf", 40) comfortaa = pygame.font.Font("Comfortaa-Regular.otf", 60) comfortaa_small = pygame.font.Font("Comfortaa-Regular.otf", 35) # Dividing lines pygame.draw.line(screen, gray, (10, 200), (590, 200)) pygame.draw.line(screen, gray, (10, 400), (590, 400)) pygame.draw.line(screen, gray, (200, 410), (200, 790)) pygame.draw.line(screen, gray, (400, 410), (400, 790)) # Today date = small_font.render(days[0], True, black, white) date_rect = date.get_rect() date_rect.topleft = 10, 15 high = small_font.render('high: ', True, black, white) high_rect = high.get_rect() high_temp = comfortaa.render(highs[0], True, black, white) htemp_rect = high_temp.get_rect() high_rect.topleft = (50, 100) htemp_rect.topleft = high_rect.topright low = small_font.render("low: ", True, black, white) low_rect = low.get_rect() low_rect.topleft = (400, 100) low_temp = comfortaa.render(lows[0], True, black, white) ltemp_rect = low_temp.get_rect() ltemp_rect.topleft = low_rect.topright condition = font.render(conditions[0], True, black, white) con_rect = condition.get_rect() con_rect.centerx = 300 con_rect.top = 5 # Make sure words don't overlap if con_rect.left < date_rect.right: con_rect.left = date_rect.right image = pygame.image.load(img_links[0]) image.set_colorkey((255, 255, 255)) img_rect = image.get_rect() img_rect.center = (300, 125) degrees = pygame.image.load("icons/%s.png" % unit) screen.blit(condition, con_rect) screen.blit(high, high_rect) screen.blit(degrees, htemp_rect.topright) screen.blit(degrees, ltemp_rect.topright) screen.blit(high_temp, htemp_rect) screen.blit(low, low_rect) screen.blit(low_temp, ltemp_rect) screen.blit(image, img_rect) screen.blit(date, date_rect) # Tomorrow date = small_font.render(days[1], True, black, white) date_rect = date.get_rect() date_rect.topleft = 10, 210 high = small_font.render('high: ', True, black, white) high_rect = high.get_rect() high_temp = comfortaa.render(highs[1], True, black, white) htemp_rect = high_temp.get_rect() high_rect.topleft = (50, 300) htemp_rect.topleft = high_rect.topright low = small_font.render("low: ", True, black, white) low_rect = low.get_rect() low_rect.topleft = (400, 300) low_temp = comfortaa.render(lows[1], True, black, white) ltemp_rect = low_temp.get_rect() ltemp_rect.topleft = low_rect.topright condition = font.render(conditions[1], True, black, white) con_rect = condition.get_rect() con_rect.centerx = 300 con_rect.top = 210 if con_rect.left < date_rect.right: con_rect.left = date_rect.right image = pygame.image.load(img_links[1]) image.set_colorkey((255, 255, 255)) img_rect = image.get_rect() img_rect.center = (300, 325) screen.blit(condition, con_rect) screen.blit(high, high_rect) screen.blit(degrees, htemp_rect.topright) screen.blit(degrees, ltemp_rect.topright) screen.blit(high_temp, htemp_rect) screen.blit(low, low_rect) screen.blit(low_temp, ltemp_rect) screen.blit(image, img_rect) screen.blit(date, date_rect) # Day 3 date = small_font.render(days[2], True, black, white) date_rect = date.get_rect() date_rect.centerx = 100 date_rect.top = 410 high = small_font.render('high: ', True, black, white) high_rect = high.get_rect() high_temp = comfortaa_small.render(highs[2], True, black, white) htemp_rect = high_temp.get_rect() high_rect.topright = (100, 630) htemp_rect.midleft = high_rect.midright low = small_font.render("low: ", True, black, white) low_rect = low.get_rect() low_rect.topright = (100, 710) low_temp = comfortaa_small.render(lows[2], True, black, white) ltemp_rect = low_temp.get_rect() ltemp_rect.midleft = low_rect.midright condition = tiny_font.render(conditions[2], True, black, white) con_rect = condition.get_rect() con_rect.centerx = 100 con_rect.top = 450 image = pygame.image.load(img_links[2]) image.set_colorkey((255, 255, 255)) img_rect = image.get_rect() img_rect.center = (100, 540) screen.blit(condition, con_rect) screen.blit(high, high_rect) screen.blit(degrees, htemp_rect.topright) screen.blit(degrees, ltemp_rect.topright) screen.blit(high_temp, htemp_rect) screen.blit(low, low_rect) screen.blit(low_temp, ltemp_rect) screen.blit(image, img_rect) screen.blit(date, date_rect) # Day 4 date = small_font.render(days[3], True, black, white) date_rect = date.get_rect() date_rect.centerx = 300 date_rect.top = 410 high = small_font.render('high: ', True, black, white) high_rect = high.get_rect() high_temp = comfortaa_small.render(highs[3], True, black, white) htemp_rect = high_temp.get_rect() high_rect.topright = (300, 630) htemp_rect.midleft = high_rect.midright low = small_font.render("low: ", True, black, white) low_rect = low.get_rect() low_rect.topright = (300, 710) low_temp = comfortaa_small.render(lows[3], True, black, white) ltemp_rect = low_temp.get_rect() ltemp_rect.midleft = low_rect.midright condition = tiny_font.render(conditions[3], True, black, white) con_rect = condition.get_rect() con_rect.centerx = 300 con_rect.top = 450 image = pygame.image.load(img_links[3]) image.set_colorkey((255, 255, 255)) img_rect = image.get_rect() img_rect.center = (300, 540) screen.blit(condition, con_rect) screen.blit(high, high_rect) screen.blit(degrees, htemp_rect.topright) screen.blit(degrees, ltemp_rect.topright) screen.blit(high_temp, htemp_rect) screen.blit(low, low_rect) screen.blit(low_temp, ltemp_rect) screen.blit(image, img_rect) screen.blit(date, date_rect) # Day 5 date = small_font.render(days[4], True, black, white) date_rect = date.get_rect() date_rect.centerx = 500 date_rect.top = 410 high = small_font.render('high: ', True, black, white) high_rect = high.get_rect() high_temp = comfortaa_small.render(highs[4], True, black, white) htemp_rect = high_temp.get_rect() high_rect.topright = (500, 630) htemp_rect.midleft = high_rect.midright low = small_font.render("low: ", True, black, white) low_rect = low.get_rect() low_rect.topright = (500, 710) low_temp = comfortaa_small.render(lows[4], True, black, white) ltemp_rect = low_temp.get_rect() ltemp_rect.midleft = low_rect.midright condition = tiny_font.render(conditions[4], True, black, white) con_rect = condition.get_rect() con_rect.centerx = 500 con_rect.top = 450 image = pygame.image.load(img_links[4]) image.set_colorkey((255, 255, 255)) img_rect = image.get_rect() img_rect.center = (500, 540) screen.blit(condition, con_rect) screen.blit(high, high_rect) screen.blit(degrees, htemp_rect.topright) screen.blit(degrees, ltemp_rect.topright) screen.blit(high_temp, htemp_rect) screen.blit(low, low_rect) screen.blit(low_temp, ltemp_rect) screen.blit(image, img_rect) screen.blit(date, date_rect) ### change for windows if (platform.system() == 'Windows'): update_time = "Last updated at " + datetime.now().strftime("%I:%M%p") else: update_time = "Last updated at " + datetime.now().strftime("%l:%M%P") ### last_update = tiny_font.render(update_time, True, gray, white) screen.blit(last_update, (5, 770)) # Rotate the display to portrait view. ### change for windows if (platform.system() == 'Windows'): graphic = pygame.transform.rotate(screen, 0) else: graphic = pygame.transform.rotate(screen, 90) ### display.blit(graphic, (0, 0)) pygame.display.update() ### change for windows if (platform.system() == 'Windows'): running = True while running: for event in pygame.event.get(): if event.type == QUIT: running = False elif event.type == KEYDOWN and event.key == K_ESCAPE: pygame.event.post(pygame.event.Event(QUIT)) pygame.quit() else: call(["./full_update"]) ### #convert_to_raw(screen) #call(["/mnt/onboard/.python/display_raw.sh"]) #index_error(error) |
|
11-09-2012, 05:10 AM | #39 |
Junior Member
Posts: 3
Karma: 10
Join Date: Oct 2012
Device: Sony PRS-505 and Kobo WiFi
|
|
11-10-2012, 01:12 PM | #40 |
Junior Member
Posts: 8
Karma: 10
Join Date: Oct 2012
Device: kobo wifi
|
|
11-12-2012, 11:42 AM | #41 | |
Addict
Posts: 348
Karma: 209937
Join Date: Jan 2012
Location: Virginia, US
Device: Kobo Wifi, Kobo Glo
|
Quote:
What I've done on my Wifi is set up a listener that starts on boot and waits for the "back" and "home" buttons to be pressed at the same time, and then starts either nickel or the weather display. I'll upload the script as soon as I have time. |
|
11-17-2012, 12:59 AM | #42 |
Junior Member
Posts: 3
Karma: 10
Join Date: Sep 2007
Device: PRS-500
|
Hi,
First of all thank you for such great development. I bought a Kobo just for that, and now I have a fancy weather display As a newbie, I have no idea about python, but I sure can follow instructions LOL, I have some questions regarding the weather software and Kobo: 1- After I setup the weather.sh with my latitude and longitude I went to worldweatheronline.com's website to check the data, turns out the temperatures on kobo are not the same that the ones on the website (using same lat/long). since this is my first day I will keep running weather.sh for a few days to compare data. Is that a reason why the info is different???? 2-Is that a way to avoid kobo going to sleep, so I can have the weather display on all the time???? 3- I understood kobo's OS is debian (or debian compatible, right??), if that so would be possible to install a webserver on it (I was thinking about using kobo as a python learning platform), for web development using python. 4- Is that a way to start weather.sh directly from kobo and not with telnet??? I saw something about this here but I have no idea how to implement (need some help). Thank you again one more time PC |
11-17-2012, 05:19 AM | #43 |
Junior Member
Posts: 8
Karma: 10
Join Date: Aug 2003
Location: Ireland
Device: Pocket PC
|
|
11-17-2012, 11:48 AM | #44 | |||
Addict
Posts: 348
Karma: 209937
Join Date: Jan 2012
Location: Virginia, US
Device: Kobo Wifi, Kobo Glo
|
Quote:
Quote:
go to sleep. To start the weather display without telnet, install this package on your Kobo. You can then switch between the weather display and the normal Kobo interface by pressing the Back and Home buttons at the same time (this will stop your Kobo from sleeping as well). Quote:
install all the necessary dependencies, which is the hard part. I know nothing about setting up a webserver, but it should be possible. It will. Or you can use the installer I linked to above. Last edited by KevinShort; 11-17-2012 at 12:09 PM. |
|||
11-17-2012, 11:28 PM | #45 |
Junior Member
Posts: 3
Karma: 10
Join Date: Sep 2007
Device: PRS-500
|
Hey Kevin,
Thank you very much. I couldn't ask for more. Everything its working and I am now running some battery test to figure out how long it will last keeping kobo on all the time and updating weather every hour. Again, I really appreciate your work and dedication cheers PC |
Tags |
hacking, kobo wifi |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Odd; Kobo-purchased book reads fine on Desktop, WiFi and Sony -but not on Kobo Touch. | beautifulsoup | Kobo Reader | 4 | 07-17-2012 10:29 AM |
Kobo Touch in cold weather | Judsuw | General Discussions | 15 | 06-02-2012 07:23 PM |
Sync epubs between Kobo app and Kobo wifi? | emilikins | Kobo Reader | 1 | 11-17-2011 05:12 PM |
Kobo Desktop App v1.7 onboard Kobo WiFi | ZombWii | Kobo Reader | 6 | 10-20-2010 01:24 PM |
Forrester upgrades sales forecast by 50% | xoox | News | 0 | 10-10-2009 05:11 AM |