home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / pub / palmos / development / undocpcp-1999-04-08.txt < prev    next >
Text File  |  2000-12-06  |  9KB  |  228 lines

  1. Flying into the Bermuda Triangle, Pilots and Palms.
  2.  
  3. Questions, comments, flames, updates to tz@execpc.com
  4.  
  5. Last Updated 4/8/99
  6.  
  7. Warning: the techniques won't work if Palm changes something, and all
  8. this should be avoided if possible, otherwise used very carefully and
  9. warn the user that it might not work on different models.
  10.  
  11. This is also a lot of rumor, hearsay, and wild speculations, though
  12. they seem to work.  So treat this information like something from a
  13. tabloid.
  14.  
  15. You should also get a copy of the Motorola Dragonball manual if you
  16. want to know what I am talking about when I refer to registers or
  17. ports or things, and of course the official Palm documentation.
  18.  
  19. Q. Why did my palm shut off although it says the battery is only low?
  20.  
  21. A. You were probably running an app that used IrDA, the serial port,
  22. or the CPU a lot.  Batteries produce lower voltage when higher current
  23. is demanded of them, and some of the chemical processes can't keep up
  24. with higher drain when low.  So when you turn it back on, it is
  25. usually in a paused mode waiting, and using less power, and the
  26. chemistry has had a chance to catch up.  Various hacks will give a
  27. battery level display and you can see the voltage change as different
  28. things are done, especially when the batteries are low.
  29.  
  30. You can see the chemical effect with a pocket flashlight: If the
  31. batteries are low, you can leave it on until you see the bulb dim.
  32. Shut it off for 90 sec to 5 minutes, turn it back on, and the bulb
  33. will glow brightly for a little while, then dim again.  What is
  34. happening is that a chemical is being produced faster than it can be
  35. cleaned up that poisons the reaction that produces the power.  After
  36. 90 seconds off, the cleaning chemistry has a chance to catch up so the
  37. battery appears to have recharged itself.  This effect will differ
  38. depending on the type of battery and if it is designed for high or low
  39. load conditions.
  40.  
  41. Q. Any Undocumented Graffiti or character processing?
  42.  
  43. A. This is actually on page 26 of the basic book but almost nowhere
  44. else - there is a next/previous field stroke, but it only works with
  45. the Address Book.  These strokes create nextField and prevField
  46. characters which can be processed by appications.  The UR to LL slash
  47. produces a linefeed (end of line, like pressing enter) and works
  48. elsewhere.  There are codes for cursor up and down (which can be bound
  49. to the vertical strokes with a hack), and several others.
  50.  
  51. Q. Any way to speed things up?
  52.  
  53. A. Reduce the wait states.  Flash on the III is normally set at 3, but
  54. should work down to 1.  On the IIIx and the V, you might try to remove
  55. an extra wait state on the DRAM designed to increase drive capability.
  56.  
  57. Q. How do I tell if certain hardware exists?
  58.  
  59. A. GHwrMiscFlags is a global that has backlight, IrDA, and some other
  60. details.  See System/Hardware.h.  FtrGet has some undocumented stuff
  61. in System/SystemMgr.h for the backlight.
  62.  
  63. Q. Anything special about the serial port?
  64.  
  65. A. The UART can produce more than standard baud rates.  Between
  66. fiddling with the PAL clock (like EcoHack does), and the very flexible
  67. baud rate divider you can do almost anything including MIDI (31250).
  68. Most PCs can only use exact divisors of 115200.  The SerOpen call will
  69. set baud rates by computation, but not take the PLL into account.
  70.  
  71. Q. What about IrDA SIR?
  72.  
  73. A. Except for the PilotPro upgrade board, the UART is multiplexed, so
  74. SerControl(OpenRef, serCtlIrDAEnable, 0, 0); will flip the UART to
  75. point to the IrDA hardware, and there is an equivalent for switching
  76. back.  For the PPro upgrade, you need to do this call but also use
  77. SysLibFind("IrSerial Library", &OpenRef); instead of "Serial Library".
  78.  
  79. Q. What about IR remote control?
  80.  
  81. A. You can generate a 40Khz carrier for a remote by setting the baud
  82. rate to 80000, 8N1, and sending a string of capital Us (0x55 hex).
  83. This will allow receiving of remote control data, and sending, but the
  84. UART transmit routine is a little slow at times, so you might need to
  85. use EcoHack in turbo mode (or equivalent).  I haven't gotten this to
  86. work fully, only the carrier.
  87.  
  88. Q. Can I do timing finer than 10mS?
  89.  
  90. A. You can change the timer register TCMP2 at 0xFFFFF610.  Shifting it
  91. right 2 results in 2.5ms.  The Palm doesn't seem to mind, but I don't
  92. know how far this can be taken.  You can also hook the interrupt,
  93. shift the frequency up, and call the original tick routine at the
  94. original rate, but keep the faster local count somewhere else.  But
  95. you will have to remember to unlink the interrupt.
  96.  
  97. NOTE: This register moved in the Dragonball EZ as used in the IIIx and
  98. the V.  There is only one timer, and the corresponding register is at
  99. 0xfffff604.
  100.  
  101. Q. Any problems or unexpected things that aren't in the official
  102. documents?
  103.  
  104. A. The battery check is done by queueing events, so if you are waiting
  105. for any event, you will get a keydown event with this code every few
  106. minutes to trigger the check which will display the low battery
  107. dialog.  Intercepting and discarding these will cause it to only see
  108. events if a real hardware event (pen, alarm, button) occurs, assuming
  109. I haven't missed some other rare event, but will also cause the low
  110. battery dialog not to be displayed.
  111.  
  112. The low battery dialog is displayed even while hotsyncing
  113. (interrupting a backup until you acknowledge it and telling you to
  114. hotsync as soon as possible :).
  115.  
  116. This also seems to interrupt the internal SMF player for long
  117. sequences (or short ones if started just before one happens to be
  118. queued).
  119.  
  120. Q. Any Heap or dynamic memory gotchas?
  121.  
  122. A. If SaveBehind is set for a form, it will only allocate memory (or
  123. fail) when the form is drawn.  And the form will successfully be
  124. drawn, but when dismissed it will crash with a fatal error if the
  125. original alloc failed.  There is no documented way to determine the
  126. exact memory required ahead of time, but allocating huge buffers at
  127. the beginning of a program is a bad thing to do - leave lots of chunks
  128. available for PalmOS.
  129.  
  130. Q. Is there any way to handle incoming serial characters
  131. asynchronously (via events instead of polling)?
  132.  
  133. A. SerSetWakeupHandler will set up a callback that can queue an event
  134. (suggest using a new keydown).  Ask me or palm devsupp for more
  135. details, but I hope to have some sample code available.
  136.  
  137. Q. Can the LCD do grayscale?
  138.  
  139. A. It can do a depth of two, and these can be 4 of 8 contrast levels
  140. but the details are involved, and I am not familiar with them.  Many
  141. of the Palm Win draw calls in 3.0 will correctly handle 2 bit depths.
  142. (someone want to contribute a full answer and a URL?).  Palm has a
  143. greyscale app note (seeing gray on www.palm.com in the devzone).
  144.  
  145. Q. What about digitized sound?
  146.  
  147. A. The current hardware is capable of audio, but the piezo speaker
  148. doesn't reproduce things clearly.  For now it can only reasonably
  149. produce monophonic rectangle wave tones.
  150.  
  151. Q. Are there some calls I should never use?
  152.  
  153. A. FtrInit and several other Init routines are used internally during
  154. the bootup and will confuse things greatly if called by an
  155. application.  You will end up resetting the Palm (or maybe lose
  156. memory) and there are better ways of doing this if this is the intent.
  157.  
  158. Q. Other things I should never do?
  159.  
  160. A. Change the PLL system clock frequency too far out of normal bounds
  161. - you will erase the memory.  I would also worry about the LCD since
  162. they tend to break if DC is applied - insure that there is always an
  163. AC signal.  Don't play with the timer used for memory refresh.
  164.  
  165. Q. How can I speed things up (Writing things on the screen).
  166.  
  167. A. Use lower level calls.  If you call a routine that formats text
  168. within a field (scrolling and splitting lines at words, etc) it will
  169. take a while to plot.  If you use WinDrawChars, it will be much
  170. faster.  If you need more speed, use bitmaps since fonts take some
  171. computation.  And even if you use bitmaps, stick to an even 16 pixel
  172. boundary (I get 8% speedups plotting something from 0-15 v.s. 8-23).
  173.  
  174. Q. Anything faster than that for screen writing?
  175.  
  176. A. If you are careful, and don't care about future compatibility, you
  177. can use the following:
  178.  
  179. #define WinDrawBitmap(b,x,y) HwrLCDDrawBitmap(x, y, b, 0)
  180.  
  181. Note that WinDrawBitmap requires word alignment and widths, but HwrLCD
  182. doesn't.  Also HwrLCD is BYTE aligned and always writes BYTES, not
  183. bits, so 6 bit wide bitmaps that are 2 bytes long per line will end up
  184. taking 16 bit wide fields on the screen.  HwrLCD ignores the width in
  185. bits.  I don't think it can decompress either, but haven't tested.
  186.  
  187. In one app, since I already aligned the fields, I simply had to alter
  188. the bitmaps to be one byte wide (they were two wide for WinDraw).  But
  189. I used to offset the characters into pairs, and that didn't work
  190. anymore.  So I had to create two sets of bitmaps, one shifted by one
  191. bit, e.g.
  192.  
  193. ######
  194. ######
  195.     ##
  196.     ##
  197.   ####
  198.   ####
  199.     ##
  200.     ##
  201. ######
  202. ######
  203.  
  204. and
  205.  
  206.  ######
  207.  ######
  208.      ##
  209.      ##
  210.    ####
  211.    ####
  212.      ##
  213.      ##
  214.  ######
  215.  ######
  216.  
  217. --------========--------========--------========
  218.  ###### ######   ###### ######   ###### ######  
  219.  ###### ######   ###### ######   ###### ######  
  220.      ##     ##       ##     ##       ##     ##  
  221.      ##     ##       ##     ##       ##     ##  
  222.    ####   ####     ####   ####     ####   ####  
  223.    ####   ####     ####   ####     ####   ####  
  224.      ##     ##       ##     ##       ##     ##  
  225.      ##     ##       ##     ##       ##     ##  
  226.  ###### ######   ###### ######   ###### ######  
  227.  ###### ######   ###### ######   ###### ######  
  228.