Vanishing draw_string - Script Writing - CHDK Forum

Vanishing draw_string

  • 5 Replies
  • 2720 Views
Vanishing draw_string
« on: 07 / September / 2014, 07:24:05 »
Advertisements
OK, i should have been a more diligent student before asking, but i don't have a lot of time these days  :)

Why the string at the end of my script suddenly disappears and doesn't last on display for 1500 ms ?

Code: [Select]
--[[
@title test
]]

require("drawings")

-- few script lines ---------------------------------

draw_string( 30, 120, ("text"), 258, 259, 2, 2)
sleep(1500)
draw.clear()
exit_alt()

Re: Vanishing draw_string
« Reply #1 on: 07 / September / 2014, 10:13:04 »
What usually happens when drawing any string (or other object) is that the Canon UI overwrites it.   So the trick is to constantly rewrite in a loop.

That's why the Lua drawing  module is so useful.  If you use it to create the information you want on the screen then you can just call draw.​redraw() from a loop.

In your case, try this :
Code: [Select]
--[[
@title test
]]

require("drawings")

-- few script lines ---------------------------------

for i=0,i<15,1 do
   draw_string( 30, 120, ("text"), 258, 259, 2, 2)
   sleep(100)
end

draw.clear()
exit_alt()
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Vanishing draw_string
« Reply #2 on: 07 / September / 2014, 10:42:34 »
getting this error msg (at for i ... line):
"attempt to compare nil with number"  :blink:

Re: Vanishing draw_string
« Reply #3 on: 07 / September / 2014, 10:54:51 »
getting this error msg (at for i ... line):
"attempt to compare nil with number"  :blink:
darn
Code: [Select]
--[[
@title test
]]

require("drawings")

-- few script lines ---------------------------------

for i=0,15,1 do
   draw_string( 30, 120, ("text"), 258, 259, 2, 2)
   sleep(100)
end

draw.clear()
exit_alt()
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Vanishing draw_string
« Reply #4 on: 07 / September / 2014, 11:00:45 »
noticed the typo before your reply  :P

The drawning is fine now.
Thank you again, glad to have a mentor like you.

Re: Vanishing draw_string
« Reply #5 on: 07 / September / 2014, 11:17:49 »
noticed the typo before your reply  :P
Wasn't a typo.  C syntax vs Lua throws me sometimes when I'm constantly switching back and forth.  That's why I usually test before I post - but that one seemed so simple that, well, you know ...
Ported :   A1200    SD940   G10    Powershot N    G16

 

Related Topics


SimplePortal © 2008-2014, SimplePortal