android
  #1  
Old 11-26-2009, 10:37 AM
ZaPx64's Avatar
ZaPx64 ZaPx64 is offline
Member
 
Join Date: Nov 2009
Location: Germany
Posts: 136
Default Firmware 1.10.04 Update

Hi there,

Creative released the new update yesterday, which brings some nice changes. I really liked the picture-turning-feature which is quite useful. They delivered a Sudoku game as well with the update which adds a new submenu named 'applications'.
The game is written in LUA and can be found in a subfolder on the player, but the source code is unfortunatly unreadable and I'm wondering whether there's an SDK or something...

Anyway, here's the full list of changes:

  • Automatically rotates photos when you turn your player sideways.
  • Adds a Sudoku game under the Applications menu .
  • Updates your player with new colorful themes.
  • Enhances the touch screen's responsiveness.
  • Ensures a "press and hold" behaviour for the Power button when you turn on/off your player.
(Via http://support.creative.com/download...pe=4&bLatest=1)

Btw, the update seems to reset all preferences of the player. You will also be requested to recalibrate the touchscreen when booting the player the first time after updating it.

Greetings, ZaP

Last edited by ZaPx64; 11-26-2009 at 10:42 AM.
Reply With Quote

Advertisement [Remove Advertisement]

  #2  
Old 11-26-2009, 10:51 AM
Olley Olley is offline
Ultra Senior Member
 
Join Date: Dec 2008
Posts: 4,894
Default

Thanks for the news, ZaP. Looks like Creative wants the X-Fi2 to succeed against the Cowons and Samsungs.
Reply With Quote

  #3  
Old 11-26-2009, 01:02 PM
nafai7 nafai7 is offline
Junior Member
 
Join Date: Feb 2009
Posts: 11
Default

They certainly have improved the touchscreen responsiveness a ton with these last two firmware updates. And the Sudoku application is a nice addition. According to Creative there will be more applications and games released in the future.

The automatic photo rotation is good too, although I noticed my music skipped once or twice when the rotation was happening.

If anyone finds out anything more about writing apps for the x-fi2 please post
Reply With Quote

  #4  
Old 11-26-2009, 08:23 PM
nafai7 nafai7 is offline
Junior Member
 
Join Date: Feb 2009
Posts: 11
Default

I emailed Creative to ask about an SDK and this was the response:

"As per the SDK, there has not been any plans yet if they will release
it since this device designed to focus as an MP3 player with added
features and not a pocket PC."

Not promising...
Reply With Quote

  #5  
Old 11-27-2009, 07:49 AM
ZaPx64's Avatar
ZaPx64 ZaPx64 is offline
Member
 
Join Date: Nov 2009
Location: Germany
Posts: 136
Default

Hm, does not sound like a good marketing strategy... However, I tried to write an application in LUA using the luac precompiler, which produced a similar code to the sudoku main file, but it did not work. I'll go on doing some experiments with it and report my findings here.
Reply With Quote

  #6  
Old 11-27-2009, 09:46 AM
Olley Olley is offline
Ultra Senior Member
 
Join Date: Dec 2008
Posts: 4,894
Default

Under the apps icon you can toggle the list display. Certainly suggests there will be at least a few more apps in there eventually. Why make a folder for apps unless you had more than one. If all we were getting was Sudoku then it could have been an icon on the home menu.

On another subject, I noticed the home screen icons can be moved around. Simply hold down on one for a couple seconds and then you can drag it to a new spot. That includes to or from the second page.
Reply With Quote

  #7  
Old 11-27-2009, 01:16 PM
nafai7 nafai7 is offline
Junior Member
 
Join Date: Feb 2009
Posts: 11
Default

Yeah I figured that out too. I emailed Creative to see if the one main button could be programmed to do something else, but it can't. But they did tell me that you can re-arrange the home icons as Olley said. I was hoping I could re-arrange some of the other menus too, but I don't think that is possible.

Creative did say they are planning on releasing more games and apps soon, I'm pleased that they are releasing updates so quickly.

So ZaP - did you put your compiled LUA program in a folder in the Applications folder? I wonder if the list of applications are hard coded into the firmware.
Reply With Quote

  #8  
Old 11-27-2009, 03:42 PM
rphunt2002 rphunt2002 is offline
Junior Member
 
Join Date: Nov 2009
Posts: 52
Default

Yeah, their LUA apps probably require a proprietary compiler.

I hope Creative doesn't get into the games and apps side too much, since general performance and operations still need major improvements.

BTW, moving the main icons around? That was available several updates back, but it had a huge impact on touch response. It's much better now.

Video playback has been improved, looks like I can now use res's like 320 X 240 w/o problems (using Handbrake). And the wmv's I was using on my original zen play fine now, and Dan***soft AVI vids work better (but not perfect).

The color icons are nicer, yes; but in the clock section the analog display is still b&w. Oops!

So - a G-sensor and LUA app support - I wonder what else hasn't been made public yet?
Reply With Quote

  #9  
Old 11-27-2009, 04:20 PM
ZaPx64's Avatar
ZaPx64 ZaPx64 is offline
Member
 
Join Date: Nov 2009
Location: Germany
Posts: 136
Default

Ok, here's what I found out concerning Apps (Btw, my list has been extended to two apps :P):
It is possible to add an app by simply creating a sub-folder in the "Applications" directory on the player. I guess it requires a 42 x 42 PNG icon to be displayed correctly, but I'm not exactly sure, I just added one for testing purposes.
The app is displayed and can be touched. However my first app didn't work since it did exactly nothing (which means it tipped with my finger on it, but nothing happened) but my second one produces an error message (hey, it's actually an advantage ).

I used a LUA 5.1 compiler and edited the output of the compiler itself. Here's the code:

Code:
white = Color.new(255,0,255)

while true do
screen:Print(1,1,"Hello World Compild", white)
screen.flip()
end
And here's what the compiler produced (it is very similar to the code of the Sudoku game...):


As you see, there is @main.lua in the middle of the code - this is the name of the file and probably needs to be edited after compiling (usually it's like C:/LUA/scripts/foo/bar.lua)
In fact, the Zen requires a compiled LUA script named MAIN.LUA to run your app (although it is currently producing errors).

Stay tuned, ZaP
Reply With Quote

  #10  
Old 11-27-2009, 07:52 PM
gsteruk gsteruk is offline
Junior Member
 
Join Date: Dec 2008
Posts: 9
Default New Firmaware - EEK!

Hey all,

Well.....i gotta say this latest firmware - is not good! Sure they have tweaked the touch screen - but in the wrong direction! to me this seems a step back! its not good at all! the audio sounds terrible - i had a perfect EQ set - now with the new update, same preset sounds terrible, and just cant get it sounding good. Sure the interface is nicer, with a new theme - big woop - id rather it sounded good. Ill be goin back to the previous update i think, this is woeful!
Reply With Quote

  #11  
Old 11-29-2009, 01:08 PM
ZaPx64's Avatar
ZaPx64 ZaPx64 is offline
Member
 
Join Date: Nov 2009
Location: Germany
Posts: 136
Default

Good news: I just wrote a fully working LUA app for my Zen. It does exactly what I want (besides it is just three lines....) and does not produce any error message.

The solution is quite simple: Scripts do not need to be compiled. The only thing you need to know is that simple things like
Code:
print("Hello World!")
does not work, because the Zen seems to use special classes(?) for visual output.

Ok, here's now how to get your own app on your Zen:
1. Create a folder in the Applications directory on your Zen, e.g. E:\Applications\MyAppName (I'm not exactly sure whether spaces are allowed here...)

2. (probably optional, not tested if it actually is needed) Add a 42 * 42 pixels PNG image which will be the icon of your app (you can as well copy the one from the Sudoku folder)

3. Your script should be written in a file named MAIN.LUA which will be executed first. For example, you can use this one:
Code:
text.size(20)
text.draw(10, 10, "Hello World!")
screen.update()
os.sleep(100)
This will flash up a small text that says Hello World! in the top left corner for a very short time (the rest of the screen will not turn black or something, it just overwrites it)

I'm looking forward to more complex scripts...

ZaP

Last edited by ZaPx64; 11-29-2009 at 01:14 PM.
Reply With Quote

  #12  
Old 11-29-2009, 03:19 PM
rphunt2002 rphunt2002 is offline
Junior Member
 
Join Date: Nov 2009
Posts: 52
Default

This will flash up a small text that says Hello World!

I tried it, it's awesome, bravo.
How did you nail down the syntax? I tried lueadec on MAIN.LUA and it crashed. I indeed tried screen.update() (which I saw in MAIN.LUA), but the text object? Did you have a tool to take MAIN.LUA apart, or just laboriously dug thru it?
Reply With Quote

  #13  
Old 11-29-2009, 05:08 PM
rphunt2002 rphunt2002 is offline
Junior Member
 
Join Date: Nov 2009
Posts: 52
Default

Well, this works:

Quote:
text.size(20);
io.input("read.txt");
x = io.read("*all");
text.draw(10, 10, x);
screen.update();
os.sleep(100);
Reply With Quote

  #14  
Old 11-30-2009, 05:01 AM
ZaPx64's Avatar
ZaPx64 ZaPx64 is offline
Member
 
Join Date: Nov 2009
Location: Germany
Posts: 136
Default

I used luadec51 with -f. This will translate the bytecode of the function number mentioned after -f and make it readable. This works will all function, except 0 (main function? I guess this could be the most important one, since some of the code fragments taken from Sudoku do not work in my apps ) and 23 (decompiler crash)

So I decompiled almost all the functions of Sudoku and created a list of commands that could be Zen-specific (some of them may be LUA standard, I haven't really coded yet with LUA):

Code:
os.time()
os.sleep(milliseconds?)

math.randomseed(n)
math.random()
math.div(a, b)

string.format(?)

fhandle = io.open(file, mode)
fhandle:write(string)
fhandle:close()

dofile(file?)

image_handle:draw(x, y, [width?], [height?])
image_handle:width()
image_handle:height()

text.size(size_in_pixel)
text.color(color_handle)
text.draw(x, y, text, [unknwon])

screen.drawline(x, y, x2, y2, color_handle)
screen.fillrect(x, y, w, h, color_handle)
screen.update()

// VVV booleans?
control.read()
control.isTouch()
touch.up()
touch.click()
x, y = touch.pos()
I encountered problems with control.xyz, touch.xyz and screen.fillrect() (I think there is a problem with color_handle)

Maybe some you can get these to work.
ZaP


//EDIT: Okay, since all of the important things are classes and classes seem to be handled like tables in LUA, I pulled out everything concerning the classes os, screen, text, control and touch (unfortunatly without the required arguments..):

//EDIT3: I just ran a script that displays each global with its tables. It reveals the complete list of commands and the fact that Zen runs a UNIX system which is kinda impressive since I (and I guess the rest of you here) thought it was a prorietary OS by Creative. If all the function arguments are found out, we're done here

Code:
GLOBAL: string table: 4015aa48
     -->  sub function: 4015a5d0
     -->  upper function: 4015a5a0
     -->  len function: 4015a6cc
     -->  gfind function: 4015a734
     -->  rep function: 4015a634
     -->  find function: 4015a7d0
     -->  match function: 4015a668
     -->  char function: 4015a838
     -->  dump function: 4015a804
     -->  gmatch function: 4015a734
     -->  reverse function: 4015a604
     -->  byte function: 4015a86c
     -->  format function: 4015a79c
     -->  gsub function: 4015a700
     -->  lower function: 4015a69c
GLOBAL: xpcall function: 4015d59c
GLOBAL: package table: 4015d084
     -->  preload table: 4015cb50
     -->  loadlib function: 4015cfbc
     -->  loaded table: 4015e384
     -->  loaders table: 4015cf48
     -->  cpath ./?.so;/usr/local/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so
     -->  config /
;
?
!
-
     -->  path ./?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/usr/local/lib/lua/5.1/?.lua;/usr/local/lib/lua/5.1/?/init.lua
     -->  seeall function: 4015cf88
GLOBAL: tostring function: 4015d840
GLOBAL: print function: 4015dda8
GLOBAL: image table: 40158d40
     -->  close function: 40158b1c
     -->  draw function: 40158b34
     -->  create function: 40158b64
     -->  width function: 40158a9c
     -->  setbg function: 40158b04
     -->  height function: 40158a84
     -->  setresource function: 40158a6c
     -->  load function: 40158b4c
     -->  fill function: 40158ad0
GLOBAL: os table: 4015b2c4
     -->  exit function: 4015b048
     -->  setlocale function: 4015ab90
     -->  date function: 4015b0b4
     -->  getenv function: 4015ac10
     -->  wait function: 4015aaf0
     -->  difftime function: 4015b080
     -->  remove function: 4015abdc
     -->  time function: 4015ab58
     -->  clock function: 4015b0e8
     -->  ostime function: 4015aabc
     -->  rename function: 4015abc4
     -->  sleep function: 4015ab24
GLOBAL: unpack function: 4015d5d0
GLOBAL: button table: 4015860c
     -->  home function: 40158510
     -->  power function: 401584dc
     -->  up function: 401584a8
     -->  hold function: 40158478
     -->  event function: 40158460
     -->  click function: 40158490
GLOBAL: require function: 4015c3e4
GLOBAL: getfenv function: 4015e0e8
GLOBAL: touch table: 40158894
     -->  click function: 40158668
     -->  hold function: 401586d0
     -->  up function: 40158734
     -->  move function: 4015869c
     -->  down function: 40158704
     -->  event function: 40158768
     -->  pos function: 40158798
GLOBAL: setmetatable function: 4015d8e8
GLOBAL: next function: 4015de10
GLOBAL: assert function: 4015e34c
GLOBAL: tonumber function: 4015d8ac
GLOBAL: io table: 4015b920
     -->  lines function: 4015b5fc
     -->  write function: 4015b4e4
     -->  close function: 4015b660
     -->  flush function: 4015b648
     -->  open function: 4015b5e4
     -->  output function: 4015b5b0
     -->  type function: 4015b4fc
     -->  read function: 4015b548
     -->  stderr file (4005c930)
     -->  stdin file (4005c910)
     -->  input function: 4015b630
     -->  stdout file (4005c920)
     -->  popen function: 4015b57c
     -->  tmpfile function: 4015b530
GLOBAL: rawequal function: 4015dd74
GLOBAL: collectgarbage function: 4015e318
GLOBAL: getmetatable function: 4015e0b4
GLOBAL: module function: 4015cb1c
GLOBAL: _VERSION Lua 5.1
GLOBAL: wav table: 40157b28
     -->  time function: 40157a38
     -->  play function: 40157a84
     -->  load function: 40157a9c
     -->  close function: 40157a50
GLOBAL: coroutine table: 4015d3b0
     -->  resume function: 4015d244
     -->  yield function: 4015d174
     -->  status function: 4015d1dc
     -->  wrap function: 4015d1a8
     -->  create function: 4015d278
     -->  running function: 4015d210
GLOBAL: rawset function: 4015dd08
GLOBAL: toint function: 4015d874
GLOBAL: control table: 401581b4
     -->  isSensor function: 40157d20
     -->  read function: 40157da4
     -->  isTouch function: 40157d54
     -->  isButton function: 40157d8c
GLOBAL: accelerometer table: 40158418
     -->  get_samplerate function: 401582ec
     -->  get_senddatatype function: 40158274
     -->  getdata function: 401581f4
     -->  close function: 40158304
     -->  set_samplerate function: 401582b0
     -->  set_senddatatype function: 40158234
     -->  open function: 4015831c
GLOBAL: screen table: 4015917c
     -->  clear function: 40158f38
     -->  update function: 40158dec
     -->  width function: 40158fa0
     -->  drawline function: 40158e94
     -->  backlight function: 40158db8
     -->  orientation function: 40158e24
     -->  height function: 40158f6c
     -->  drawpixel function: 40158e5c
     -->  fillrect function: 40158f04
     -->  drawrect function: 40158ecc
GLOBAL: color table: 40159374
     -->  a function: 401591b8
     -->  r function: 40159248
     -->  b function: 401591e8
     -->  g function: 40159218
     -->  new function: 40159278
GLOBAL: text table: 401594a8
     -->  color function: 4015941c
     -->  draw function: 401593b4
     -->  size function: 401593e8
GLOBAL: math table: 4015a4e8
     -->  max function: 40159df0
     -->  log function: 40159e20
     -->  huge 1.7976931348623e+308
     -->  acos function: 4015a0ec
     -->  pi 3.1415926535898
     -->  ldexp function: 40159e88
     -->  sinh function: 40159c90
     -->  tanh function: 40159bf8
     -->  sqrt function: 40159c2c
     -->  cos function: 40159fb4
     -->  deg function: 40159f84
     -->  tan function: 40159bc4
     -->  cosh function: 40159fe8
     -->  randomseed function: 40159cc8
     -->  random function: 40159cfc
     -->  rad function: 40159d2c
     -->  frexp function: 40159ebc
     -->  ceil function: 4015a01c
     -->  floor function: 40159f24
     -->  pow function: 40159d5c
     -->  abs function: 4015a11c
     -->  div function: 4015a14c
     -->  modf function: 40159d90
     -->  asin function: 4015a0b8
     -->  min function: 40159dc0
     -->  mod function: 40159ef0
     -->  fmod function: 40159ef0
     -->  log10 function: 40159e54
     -->  atan2 function: 4015a084
     -->  exp function: 40159f54
     -->  sin function: 40159c5c
     -->  atan function: 4015a050
GLOBAL: debug table: 40159b08
     -->  getupvalue function: 40159648
     -->  debug function: 40159768
     -->  sethook function: 401595f8
     -->  getmetatable function: 40159660
     -->  gethook function: 40159738
     -->  setmetatable function: 4015958c
     -->  setlocal function: 401595c4
     -->  traceback function: 4015953c
     -->  setfenv function: 40159610
     -->  getinfo function: 40159704
     -->  setupvalue function: 40159574
     -->  getlocal function: 401596d0
     -->  getregistry function: 40159698
     -->  getfenv function: 40159750
GLOBAL: pcall function: 4015dddc
GLOBAL: table table: 4015c370
     -->  setn function: 4015c024
     -->  insert function: 4015c08c
     -->  getn function: 4015c0f4
     -->  foreachi function: 4015c12c
     -->  maxn function: 4015c0c0
     -->  foreach function: 4015c160
     -->  concat function: 4015c194
     -->  sort function: 4015bff0
     -->  remove function: 4015c058
GLOBAL: pairs function: 4015d4b0
GLOBAL: type function: 4015d808
GLOBAL: audio table: 40157ca8
     -->  mute function: 40157be8
     -->  channel function: 40157bb4
     -->  beep function: 40157b80
     -->  volume function: 40157c1c
GLOBAL: newproxy function: 4015d414
GLOBAL: select function: 4015d950
GLOBAL: _G table: 4015ea68
     -->  string table: 4015aa48
     -->  xpcall function: 4015d59c
     -->  package table: 4015d084
     -->  tostring function: 4015d840
     -->  print function: 4015dda8
     -->  image table: 40158d40
     -->  os table: 4015b2c4
     -->  unpack function: 4015d5d0
     -->  button table: 4015860c
     -->  require function: 4015c3e4
     -->  getfenv function: 4015e0e8
     -->  touch table: 40158894
     -->  setmetatable function: 4015d8e8
     -->  next function: 4015de10
     -->  assert function: 4015e34c
     -->  tonumber function: 4015d8ac
     -->  io table: 4015b920
     -->  rawequal function: 4015dd74
     -->  collectgarbage function: 4015e318
     -->  getmetatable function: 4015e0b4
     -->  module function: 4015cb1c
     -->  _VERSION Lua 5.1
     -->  wav table: 40157b28
     -->  coroutine table: 4015d3b0
     -->  rawset function: 4015dd08
     -->  toint function: 4015d874
     -->  control table: 401581b4
     -->  accelerometer table: 40158418
     -->  screen table: 4015917c
     -->  color table: 40159374
     -->  text table: 401594a8
     -->  math table: 4015a4e8
     -->  debug table: 40159b08
     -->  pcall function: 4015dddc
     -->  table table: 4015c370
     -->  pairs function: 4015d4b0
     -->  type function: 4015d808
     -->  audio table: 40157ca8
     -->  newproxy function: 4015d414
     -->  select function: 4015d950
     -->  _G table: 4015ea68
     -->  gcinfo function: 4015e11c
     -->  rawget function: 4015dd3c
     -->  loadstring function: 4015de48
     -->  ipairs function: 4015d508
     -->  fh file (405640b0)
     -->  dofile function: 4015e268
     -->  setfenv function: 4015d91c
     -->  load function: 4015de7c
     -->  error function: 4015e234
     -->  loadfile function: 4015e078
GLOBAL: gcinfo function: 4015e11c
GLOBAL: rawget function: 4015dd3c
GLOBAL: loadstring function: 4015de48
GLOBAL: ipairs function: 4015d508
GLOBAL: fh file (405640b0)
GLOBAL: dofile function: 4015e268
GLOBAL: setfenv function: 4015d91c
GLOBAL: load function: 4015de7c
GLOBAL: error function: 4015e234
GLOBAL: loadfile function: 4015e078

Last edited by ZaPx64; 11-30-2009 at 01:13 PM.
Reply With Quote

  #15  
Old 11-30-2009, 02:09 PM
ThievingSix ThievingSix is offline
Member
 
Join Date: Aug 2008
Posts: 218
Default

Well that's quite interesting. I'm curious to exactly how the arguments are going to be found out other than brute force testing but it will be interesting.

Having just gotten the X-Fi2 and stumbling onto this should be fun. I'm going to play around and see what we can do. I wonder if all those functions can actually be called plain text.

Was just testing with screen.fillrect(), proof of concept:
Code:
black = color.new(0, 0, 0);
screen.clear();
screen.fillrect(0, 0, 400, 240, black);
screen.update();
background = image.load("hello.jpg");
background:draw(0, 0, 400, 240);
screen.update();
os.sleep(200);
Here's an app that waits for input(touch). I used http://www.geocities.jp/ono_tetsu/gnocl/doc/hello3.jpg renamed hello.jpg in the app. It runs, waits for a touch, then outputs the coords of the touch. Press the home button to exit:
Code:
black = color.new(0, 0, 0)
text.size(20);
text.color(black);
screen.clear();
background = image.load("hello.jpg");
background:draw(0, 0, 400, 240);
screen.update();
while true do
  if control.read() == 1 and control.isTouch() == 1 and (touch.up() == 1 or touch.click() == 1) then
    background = image.load("hello.jpg");
    background:draw(0, 0, 400, 240);
    screen.update();
    x, y = touch.pos();
    text.draw(10,10,x);
    text.draw(10,30,y);
    screen.update();
  end;
  if button.home() == 1 then
    break;
  end;
  os.sleep(10);
end;
Another proof of concept, a "gui" is created(background + "button"), click the button to exit:
Code:
color_black = color.new(0,0,0);
color_white = color.new(255,255,255);
color_blue = color.new(0,0,255);
color_red = color.new(255,0,0);
color_green = color.new(0,255,0);

screen.clear();

screen.fillrect(0,0,400,240,color_black);
text.color(color_green);
text.size(20);
screen.drawrect(10,10,100,40,color_white);
text.draw(15,15,"Exit App");
text.color(color_red);

screen.update();

while true do
  if (control.read() == 1) and (control.isTouch() == 1) and (touch.up() == 1 or touch.click() == 1) then
    x, y = touch.pos();
    if ((y > 10) and (y < 40)) and ((x > 10) and (x < 100)) then
      break;
    end;
    screen.fillrect(10,50,40,40,color_black);
    text.draw(10,50,x);
    text.draw(10,70,y);
    screen.update();
  end;
  os.sleep(10);
end;
Well that's enough for proof of concepts, I'll be trying to figure out the argument list for most of the functions. It seems that 0, 0 to 380, 235 is our zone for touch presses.

Last edited by ThievingSix; 11-30-2009 at 04:05 PM.
Reply With Quote

  #16  
Old 11-30-2009, 04:18 PM
rphunt2002 rphunt2002 is offline
Junior Member
 
Join Date: Nov 2009
Posts: 52
Default

ah, now it's getting fun. I'll poke around with this stuff, i was frustrated with fillrect yesterday.
Reply With Quote

  #17  
Old 11-30-2009, 10:09 PM
rphunt2002 rphunt2002 is offline
Junior Member
 
Join Date: Nov 2009
Posts: 52
Default

OK, I'm starting to grok the syntax, thanks to these posts (I'm not a LUA person either yet). I was soooo close in my experiments, but now I see where I went astray.

Indeed many of the functions listed are standard LUA (e.g. string.format), hoping they use the same params. Buut I see accelerometer mentioned too.

I'm thinking a scrollable text reader to start.

Last edited by rphunt2002; 11-30-2009 at 10:35 PM.
Reply With Quote

  #18  
Old 12-01-2009, 04:54 AM
ZaPx64's Avatar
ZaPx64 ZaPx64 is offline
Member
 
Join Date: Nov 2009
Location: Germany
Posts: 136
Default

I experienced some problems with fillrect as well (probably due to color.new) and I'm glad you found out how it works @ThievingSix, this is good work man!
Yesterday I tried out a few scripts using the accelerometer class but without any result. Since I'm a hobby game designer and programmer, I guess I'll try starting a small game project, thanks to all of you for your help with that.

//EDIT: Btw, the screen resolution is 400 * 240 Pixels, so that is the zone for touch input.

- ZaP
Reply With Quote

  #19  
Old 12-01-2009, 11:32 AM
ThievingSix ThievingSix is offline
Member
 
Join Date: Aug 2008
Posts: 218
Default

Well I can't actually get anything beyond 380x235 when I'm touching.

Wanted to get the accelerometer working..but I didn't. I did however get some data:

Code:
color_black = color.new(0,0,0);
color_white = color.new(255,255,255);
color_blue = color.new(0,0,255);
color_red = color.new(255,0,0);
color_green = color.new(0,255,0);

screen.clear();
text.size(20);
text.color(color_white);

while true do
  x = accelerometer.getdata();
  y = accelerometer.get_senddatatype();
  z = accelerometer.get_samplerate();
  screen.fillrect(0,0,400,240,color_black);
  text.draw(10,10,"Accelerometer Test");
  text.draw(10,30,x);
  text.draw(10,50,y);
  text.draw(10,70,z);
  screen.update();
  if (control.read() == 1) and (button.home() == 1) then
    break;
  end;
  os.sleep(10);
end;
x: Outputs 0 always. It's probably a pointer which is telling me I'm getting NULL for a result.
y: Outputs...nothing.
z: Outputs(from the values I've noticed) -1, 8, 16, 1000, 500, 250, 64, 125. I get different values depending on how I hold it. When it's flat I get 8, 16, 1000. When it's vertical 500 gets thrown around. 90* angle? 125 and 64 as well. Way to random and way to general for use. Which leads me to think, can this thing only detect angles? If so that's a huge disappointment.

Last edited by ThievingSix; 12-01-2009 at 12:18 PM.
Reply With Quote

  #20  
Old 12-01-2009, 11:14 PM
rphunt2002 rphunt2002 is offline
Junior Member
 
Join Date: Nov 2009
Posts: 52
Default

Very very simple touch drag test [TIGHTENED UP & REPOSTED]
I think this shows how the touch screen responds. It seems to be better about fast motions than slow, as it's probably less overall samples to process when fast. Also, it really shows how a fingernail works better than a finger tip.
To close, tap the upper left corner.

Code:
 
blk = color.new(0,0,0);
wht = color.new(255,255,255);
red = color.new(255,0,0);

function do_bg()
 screen.clear();
 screen.fillrect(0,0,400,240,blk);
end;
function do_out(x,y)
 do_bg();
 text.color(red);
 text.draw(10,10,x);
 text.draw(10,30,y);
 text.color(wht);
 text.draw(x,y,"<>");
 screen.update();
end;
do_out(0,0);

while true do
 if (control.read() == 1) and (control.isTouch() == 1) then
  if (touch.move() == 1) then
   x,y = touch.pos();
   do_out(x,y);
  end;
  if (touch.click() == 1) then
   x,y = touch.pos();
   if (y < 40) and (x < 100) then
     break;
   end;
  end;
 end;
 os.sleep(1);
end;

Last edited by rphunt2002; 12-02-2009 at 10:47 PM. Reason: code revised
Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 05:22 AM.