- create a thread that runs forever:
- wake it up no more than 60 times per second to poll iCP for data. The nubs are only updated 40 times per second.
- The digital controls are updated any time you need them.
- the more you poll it, the more power the iCP will use because you won't let it go back to sleep as often. <img src='http://boards.openpandora.org/public/style_emoticons/<#EMO_DIR#>/smile.gif' class='bbc_emoticon' alt=':)' />
- here is a simple poll for digital controls:
- send <0xA5> to poll for game button data
#define CMD_GET_DIGITALS 0xA5
- wait for two bytes to be received: <byte A> and <byte B> in that order
- byte A has these bits active ('1' = pressed, '0' = released):
#define GB_DPAD_LEFT 2 //A
#define GB_DPAD_RIGHT 1 //A
#define GB_DPAD_UP 0 //A
#define GB_DPAD_DOWN 3 //A
#define GB_SHLDR_LEFT 4 //A
- byte B has these bits active ('1' = pressed, '0' = released):
#define GB_SHLDR_RIGHT 6 //B
#define GB_BTN_A 3 //B
#define GB_BTN_B 5 //B
#define GB_BTN_X 4 //B
#define GB_BTN_Y 2 //B
#define GB_BTN_START 1 //B
#define GB_BTN_SELECT 0 //B
- All other bits in these bytes will be '0'
- here is a simple poll for analog controls:
- send <0x46><0x01> to iCP. This enables analog scanning. By default it is off to save power.
#define CMD_FORCE_NUB_SCAN 0x46
#define SET_ON 0x01
- the iCP will respond with <0x80> when done. The nubs are now active.
#define RESP_OKAY 0x80
- send <0x87> to poll for analog positions
#define CMD_GET_ANALOGS 0x87
- wait for four bytes to be received: <Nub1 X> <Nub1 Y> <Nub2 X> <Nub2 Y>
- the bytes are signed. The values will range from -32 to +32.
- +32 is full up or full right
- -32 is full down or full left
- 0,0 is center of course
- here is a routine that should be added (probably to start of infinite thread before the big while(1) loop):
- To see if an iCP is connected to the iDevice, send <0xB3>
#define CMD_PING_ICP 0xB3
- The reply will be <0x44><0x88><0xCC> if connected and had enough time to initialize. No reply means the iCP is not connected or
hasn't finished booting and initializing yet. We have to figure out how long that is but for now, no wait is okay as
long as the app isn't started immediately after waking the phone up.
#define ICP_ALIVE1 0x44
#define ICP_ALIVE2 0x88
#define ICP_ALIVE3 0xCC
- If no response is given before the end of a timeout period, no communication to the iCP should happen at all since it is presumed
missing. You could also try multiple attempts in case of a communication error.
- before you close your app, you should turn off the unused features
- Example: turn off the analog nub polling
- send <0x46><0x00> to iCP.
#define CMD_FORCE_NUB_SCAN 0x46
#define SET_OFF 0x00
- the iCP will respond with <0x80> when done. The nubs are now off.
#define RESP_OKAY 0x80
- Controlling the charger is done in hardware/iCP firmware by default, but there are manual settings to force it off or let it turn back
on. You can also monitor the battery voltage and make a little battery picture in your application or something like that.
- You can check the iCP's version number by sending <0x39>
#define CMD_GET_ID 0x39
- the response is a long string of characters ending with a carriage return and line feed.
- You can check the battery's voltage by sending <0xAA>
#define CMD_GET_BATT_VOLTS 0xAA
- the response will be three readable characters in this example format: 405 <-- This means 4.05 volts.
- You can check the battery for a general level by sending <0x55>
#define CMD_GET_BATT_LEVEL 0x55
- The response will be a single byte with the following significance.
#define BATT_FULL 6
#define BATT_ALMOST_FULL 5
#define BATT_3_4_FULL 4
#define BATT_HALF_FULL 3
#define BATT_1_4_FULL 2
#define BATT_ALMOST_DEAD 1
#define BATT_DEAD 0
- The definition for these levels are estimated right now and not expected to be particularly accurate.
- You can check the status of the charger to the iDevice by sending <0xDE>
#define CMD_GET_CHGR_STATUS 0xDE
- The response will be one byte signifying either on or off as follows:
#define SET_ON 0x01
#define SET_OFF 0x00
- You can force the charger to the iDevice to be on or off by sending <0x2A>
#define CMD_FORCE_CHARGER 0x2A
With either one of these parameter to turn on or off:
#define SET_ON 0x01
#define SET_OFF 0x00
- The response will be one byte to signify if the action could be completed
#define RESP_OKAY 0x80
#define RESP_NOT_OKAY 0x81
- You can always force the charger off but you cannot force it on if the iCP detects a low battery or an external charger is already
plugged in
- If you don't need to check battery levels, you can shut that feature off to save power
- Send the command <0x51>
#define CMD_FORCE_BATT_SCAN 0x51
With either one of these parameter to turn on or off:
#define SET_ON 0x01
#define SET_OFF 0x00
- The response will be a single byte to signify if the action could be done:
#define RESP_OKAY 0x80
#define RESP_NOT_OKAY 0x81
- The action will be denied if battery charging is on because the device must constantly monitor the battery. If you
successfully turn it off, it will be re-enabled automatically if charging is started again.
- The activity of the power LED can be changed manually by sending the command <6D>
#define CMD_FORCE_LED_CTRL 0x6D
- Then send the parameter to tell the iCP if you want control of the LED or not:
#define SET_ON 0x01
#define SET_OFF 0x00
- ON means you want to override the iCP's internal control. The LED will be forced off at this point.
- OFF means you want to give back control to the iCP
- The response will always be positive:
#define RESP_OKAY 0x80
- Once control is established, turn the LED ON with the command <0xFF>
#define CMD_SET_LED 0xFF
- Then send the parameter for on or off:
#define SET_ON 0x01
#define SET_OFF 0x00
- The response will signify if the action could be completed:
#define RESP_OKAY 0x80
#define RESP_NOT_OKAY 0x81
- If you have not taken control of the LED, your request will be denied with a not okay reply.
- The activity of the power LED can be changed to alter its behavior when the iCP hardware has control of it.
Currently, the iCP uses the LED to indicate power status and internal battery low conditions only.
- Send the command <0xE4>
#define CMD_SET_LED_MODE 0xE4
- Send one of the parameters to change the mode:
#define LED_PULSE_DOUBLE 0
#define LED_PULSE_FAST 1
#define LED_PULSE_INVERSE 2
#define LED_NO_PULSE 3
#define LED_LOW_BATT_IND 4
- Pulse double: LED is normally off but blinks once every 5 seconds. It will do a double blink if the battery is low.
- Pulse fast: LED is normally off but blinks once every 5 seconds. If the battery is low, it will change blink rate to
once every 1 second.
- Pulse inverse: LED is normally on but blinks off once every 5 seconds when battery is low
- No pulse: LED is always on unless battery is low. Then it stays off until battery is recharged (to a certain threshold).
- Low batt ind: LED is always off unless battery is low. Then it stays on until battery is recharged (to a certain threshold).
- There are many bytes of non-volatile memory in the iCP that can be used to store anything.
- To read a byte of memory send the command <0x9A>
#define CMD_READ_EEPROM 0x9A
- Then send the two byte address of the single byte to read. The range is 0 - 511:
<low byte><highbyte>
- The response will be the data as a single byte reply. If the address is out of range, the response will be a <0x00>.
- To write a byte, send the command <0x7A>
#define CMD_WRITE_EEPROM 0x7A
- Then send the two byte address of the single byte to write. The range is currently 0 - 503. Currently the upper 8
bytes are reserved for the iCP's internal use and for serial numbers.
<low byte><highbyte>
- Next send a security byte to verify this operation is to happen:
#define SECURE_EE_BYTE 0x19
- Then send the single byte of data to write
- The response will signify if the action could be completed:
#define RESP_OKAY 0x80
#define RESP_NOT_OKAY 0x81
- Attempting to write out of range will be denied.
- The baud rate of communication can be changed at any time. The default on power up will always be 9600bps though.
This way the iCP will always come up at a known speed regardless of what app tried to change it.
- To set the baud rate, send the command <0xC2>
#define CMD_CHANGE_BAUD_RATE 0xC2
- Then send the single byte parameter for the new rate:
#define BAUD_RATE_9600 1
#define BAUD_RATE_19200 2
#define BAUD_RATE_38400 3
#define BAUD_RATE_57600 4
#define BAUD_RATE_115200 5
- The iCP will immediate reply at the current baud rate with a reply signifying if the action can be done:
#define RESP_OKAY 0x80
#define RESP_NOT_OKAY 0x81
- If the parameter sent is not supported, the action will be denied. Otherwise it will proceed.
- If the action is accepted, the iCP will wait 2 milliseconds, change the rate and continue on waiting for new
commands at the new baud rate until it is changed again or until power is lost.
- Firmware upgrading:
- Protocol not publicly available
- View New Content
- OpenPandora
- General Information
-
Emulation
- Acorn Archimedes
- Acorn BBC Micro
- Amstrad CPC
- Android
- Arcade Machines
- Atari Classic Computer
- Atari ST
- Atari VCS7800
- Commodore Amiga
- Commodore 64 (and more)
- HP-48GX Calculator
- Laser Disc Arcade
- MS-DOS
- NEC PC Engine / TurboGrafx 16
- Nintendo Entertainment System
- Nintendo GameBoy / GameBoy Color
- Super Nintendo
- Nintendo GameBoy Advance
- Nintendo DS
- Sega Master System / GameGear
- Sega Genesis / MegaDrive and AddOns
- Sega Saturn
- Sharp MZ-Series
- SNK NeoGeo Pocket
- Sony MSX
- Sony PlayStation 1
- Sony PSP
- Texas Instruments TI-99
- ZX Spectrum
- Community
- Development
- Contact us
- Donate
-
More






