Professional Documents
Culture Documents
START
INITIAL SETUP
Start
Initial Setup
include P18F14K22.INC
Is Button Pressed?
Yes
Set X, Y & Z Data Values To Show Current Mode Declare Variables Output Mode Data to LEDs
Dot
Define Definitions
Is Y Value Below Threshold No Adjust Sensitivity Increase Threshold Depending On Current Sensitivity
Yes
Return
Is X Value Below Threshold No Adjust Sensitivity Decrease Threshold Depending On Current Sensitivity
Yes
Yes
Goto Start
Get X Data
Start
Get Y Data
Start
Get Z Data
Start
Send X Data
Start
Send Y Data
Start
Send Z Data
Start
Return
Return
Yes Convert from 2's Compliment to Standard Format Convert from 2's Compliment to Standard Format Convert from 2's Compliment to Standard Format
No
Return
Return
Return
Return
I2Ctx
Start
I2Crx
Start
Generate I2C start condition idle Send Device Address and write bit idle Send Register Address idle
Generate I2C start condition idle Send Device Address and write bit idle Send Register Address idle Generate repeated start condition idle
Send Device Address and read bit Idle Enable receive mode. Idle No Transfere received data to i2cdat Idle Generate Stop Condition Are any status bits still set? Is transmit in progress?
Transmit Data
Increase Sensitity
Start
Decrease Sensitity
Start
No
Return
No
Return
Yes Output Data to X led row to show Tilt has been recognised
Yes Output Data to X led row to show Tilt has been recognised
No
No
Change Mode
Start
No
Return
Yes Output Data to Y led row to show Tilt has been recognised Should 2g mode be active? No Should 4g mode be active? Yes Set to 2g Mode
No
Yes
Set to 4g Mode
Yes
Set to 8g Mode
Goto Main
Flip function
Start
Is bit:0 of temporary variable set No Is bit:1 of temporary variable set No Is bit:2 of temporary variable set No Is bit:3 of temporary variable set No Is bit:4 of temporary variable set No Is bit:5 of temporary variable set No Is bit:6 of temporary variable set No Is bit:7 of temporary variable set No Return
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Dot conversion
Start
Clear output
Yes
No
Move converted result to xoutput. Load yraw to be converted. Output = 00000010 Then Return Convert data to dot pattern Yes
No
Yes
No
No
Yes
Yes
No
No Convert data to dot pattern Output = 00001000 Then Return Move converted result to zoutput. No Yes Is data less than 0x78
Yes
No
Yes
Return
Yes
No
No
Yes
Yes
No
No
Yes
Yes
No
No
Yes
line conversion
Start
Clear output
Start
Yes
No
No
Yes
Yes
No
Yes
Yes
No
Move converted result to youtput. Load zraw to be converted. Output = 11000000 Then Return
No
Yes
Yes
No
Yes
Yes
No
No
Yes
Return
Yes
No
No
Yes
Yes
No
No
Yes
Yes
No
No
Yes