Difference between revisions of "Component: GameCode (Misc Circuit)"
From Flowcode Help
Jump to navigationJump to searchLine 17: | Line 17: | ||
==Component Source Code== | ==Component Source Code== | ||
− | Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/ | + | Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_temp/GameCode_Master.fcfx FC_Comp_Source_temp/GameCode_Master.fcfx] |
− | Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/ | + | Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_temp/GameCode_Master.fcfx FC_Comp_Source_temp/GameCode_Master.fcfx] |
==Detailed description== | ==Detailed description== | ||
Line 101: | Line 101: | ||
[[File:GSMInject.jpg]] | [[File:GSMInject.jpg]] | ||
+ | |||
+ | |||
Line 114: | Line 116: | ||
==Macro reference== | ==Macro reference== | ||
− | === | + | ===BatteryRead=== |
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''BatteryRead''' | ||
+ | |- | ||
+ | | colspan="2" | Read and return the voltage level of the battery in millivolt. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | ===DisplayBrightness=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''DisplayBrightness''' |
+ | |- | ||
+ | | colspan="2" | Control the brightness of the display. | ||
+ | |- | ||
|- | |- | ||
− | | | + | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE |
+ | | width="90%" | Value | ||
|- | |- | ||
+ | | colspan="2" | Enter value from 0 to 15 | ||
|- | |- | ||
− | | width="10%" align="center" | [[File:Fc9- | + | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID |
− | | width="90%" | | + | | width="90%" style="border-top: 2px solid #000;" | ''Return'' |
+ | |} | ||
+ | |||
+ | |||
+ | ===DisplayClear=== | ||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
− | | | + | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] |
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''DisplayClear''' | ||
|- | |- | ||
− | | | + | | colspan="2" | Clear the display. |
− | |||
|- | |- | ||
− | |||
|- | |- | ||
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
Line 157: | Line 182: | ||
− | === | + | ===DisplayWriteNumber=== |
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''DisplayWriteNumber''' |
|- | |- | ||
− | | colspan="2" | | + | | colspan="2" | Show a number ranging from 000 to 999 on the display. Number is printed vertically. |
|- | |- | ||
|- | |- | ||
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
− | | width="90%" | | + | | width="90%" | Value |
|- | |- | ||
− | | colspan="2" | | + | | colspan="2" | Enter a number from 0 to 999. |
|- | |- | ||
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9- | + | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID |
| width="90%" style="border-top: 2px solid #000;" | ''Return'' | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
|} | |} | ||
− | === | + | ===EEReadValue=== |
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''EEReadValue''' |
|- | |- | ||
− | | colspan="2" | | + | | colspan="2" | Retreives a value from none volitile memory |
|- | |- | ||
|- | |- | ||
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
− | | width="90%" | | + | | width="90%" | Address |
|- | |- | ||
− | | colspan="2" | 0 | + | | colspan="2" | Address to write to, Range: 0-255 |
|- | |- | ||
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9- | + | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE |
| width="90%" style="border-top: 2px solid #000;" | ''Return'' | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
|} | |} | ||
Line 219: | Line 244: | ||
− | === | + | ===Initialise=== |
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise''' |
+ | |- | ||
+ | | colspan="2" | Initializes all present hardware and communication. Place this at the very start of your code. | ||
|- | |- | ||
− | |||
|- | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | ===LedsWrite=== | ||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
− | | width="10%" align="center" | [[File:Fc9- | + | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] |
− | | width="90%" | | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''LedsWrite''' |
+ | |- | ||
+ | | colspan="2" | Set the button-leds. MSB = leftmost led LSB = rightmost led | ||
|- | |- | ||
− | |||
|- | |- | ||
− | | width="10%" align="center" | [[File:Fc9- | + | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE |
− | | width="90%" | | + | | width="90%" | Value |
|- | |- | ||
− | | colspan="2" | | + | | colspan="2" | MSB = leftmost dot, LSB = rightmost dot |
|- | |- | ||
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
Line 276: | Line 310: | ||
− | === | + | ===MP3PlayTrack=== |
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''MP3PlayTrack''' |
|- | |- | ||
− | | colspan="2" | | + | | colspan="2" | Plays track from the selected folder. MP3 & Advert folder track numbers should be 4 characters long e.g. "0001-anyname.mp3". Other folder track numbers should be 3 characters long e.g. "001-anyname.mp3". |
|- | |- | ||
|- | |- | ||
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
− | | width="90%" | | + | | width="90%" | Directory |
|- | |- | ||
− | | colspan="2" | | + | | colspan="2" | 0=Root, 01=Folder "01" - 99=Folder "99", 100=Folder "MP3", 101=Advert |
|- | |- | ||
− | | width="10%" align="center" | [[File:Fc9- | + | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT |
− | | width="90%" | | + | | width="90%" | Track |
|- | |- | ||
− | | colspan="2" | | + | | colspan="2" | Track number 1 = "001.mp3" / "0001.mp3" |
− | |||
− | |||
− | |||
− | |||
− | |||
|- | |- | ||
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
Line 305: | Line 334: | ||
− | === | + | ===MP3SendCommand=== |
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''MP3SendCommand''' |
|- | |- | ||
− | | colspan="2" | | + | | colspan="2" | Send commands to MP3 module. Check datasheet for info. |
|- | |- | ||
|- | |- | ||
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
− | | width="90%" | | + | | width="90%" | Command |
|- | |- | ||
− | | colspan="2" | | + | | colspan="2" | |
|- | |- | ||
− | | width="10%" align="center | + | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE |
− | | width="90%" | + | | width="90%" | Para1 |
− | |||
− | |||
− | |||
− | |||
− | |||
|- | |- | ||
− | | | + | | colspan="2" | |
− | |||
|- | |- | ||
− | | | + | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE |
+ | | width="90%" | Para2 | ||
|- | |- | ||
− | + | | colspan="2" | | |
− | |||
− | |||
− | |||
− | | colspan="2" | | ||
|- | |- | ||
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
Line 343: | Line 363: | ||
− | === | + | ===MP3SetVolume=== |
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''MP3SetVolume''' |
+ | |- | ||
+ | | colspan="2" | Sets the volume level for the MP3 module | ||
+ | |- | ||
|- | |- | ||
− | | | + | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE |
+ | | width="90%" | Volume | ||
|- | |- | ||
+ | | colspan="2" | Range: 0 (min) - 30 (max) | ||
|- | |- | ||
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
Line 357: | Line 382: | ||
− | === | + | ===PlayNote=== |
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''PlayNote''' |
|- | |- | ||
− | | colspan="2" | | + | | colspan="2" | Output a single note on the buzzer. Specify the desired frequency (Hz) and duration (ms). |
|- | |- | ||
|- | |- | ||
− | | width="10%" align="center | + | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT |
− | | width="90%" | + | | width="90%" | Frequency |
− | |||
− | |||
− | |||
− | |||
− | |||
|- | |- | ||
− | | | + | | colspan="2" | Sets the pitch for the note in Hz. Range 1-20000 Hz |
− | |||
|- | |- | ||
− | | | + | | width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG |
+ | | width="90%" | Duration | ||
|- | |- | ||
− | | | + | | colspan="2" | Time period to play the note for in milliseconds. Range 0-65535 ms |
− | |||
− | |||
− | |||
− | |||
|- | |- | ||
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
Line 390: | Line 406: | ||
− | === | + | ===PotRead=== |
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''PotRead''' |
|- | |- | ||
− | | colspan="2" | | + | | colspan="2" | Read and return the value of the potentiometer. If desired, give the upper limit to scale the output value. Enter "MaxValue = 0" to skip scaling and get the byte value (0-255) |
|- | |- | ||
|- | |- | ||
− | | width="10%" align="center" | [[File:Fc9- | + | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT |
− | | width="90%" | | + | | width="90%" | MaxValue |
|- | |- | ||
− | | colspan="2" | | + | | colspan="2" | Scale the return value. Enter 0 to skip. |
|- | |- | ||
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9- | + | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT |
| width="90%" style="border-top: 2px solid #000;" | ''Return'' | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
|} | |} | ||
− | === | + | ===PwrLedSet=== |
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''PwrLedSet''' |
|- | |- | ||
− | | colspan="2" | Control the | + | | colspan="2" | Control the PWR LED. 0 = red + green 1 = red 2 = green |
|- | |- | ||
|- | |- | ||
Line 421: | Line 437: | ||
| width="90%" | Value | | width="90%" | Value | ||
|- | |- | ||
− | | colspan="2" | | + | | colspan="2" | 0 = red + green, 1 = red, 2 = green |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
|- | |- | ||
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID |
Revision as of 12:01, 3 February 2023
Author | Jef De Bruyne |
Version | 1.0 |
Category | Misc Circuit |
Contents
GameCode component
A small handheld device designed for creating embedded games. Complete with a 8 x 16 LED display, 4-Way DPAD with 4 additional push switches Buzzer, Vibration, MP3 Player, Potentiometer and Lithium battery management. Programmed via USB.
Component Source Code
Please click here to download the component source project: FC_Comp_Source_temp/GameCode_Master.fcfx
Please click here to view the component source code (Beta): FC_Comp_Source_temp/GameCode_Master.fcfx
Detailed description
No detailed description exists yet for this component
Examples
GSM Example
Example should show the following on the display on the panel and on the hardware.
The AT injector component allows us to simulate the response of the GSM module.
Macro reference
BatteryRead
![]() |
BatteryRead |
Read and return the voltage level of the battery in millivolt. | |
![]() |
Return |
DisplayBrightness
![]() |
DisplayBrightness |
Control the brightness of the display. | |
![]() |
Value |
Enter value from 0 to 15 | |
![]() |
Return |
DisplayClear
![]() |
DisplayClear |
Clear the display. | |
![]() |
Return |
DisplayWrite
DisplayWriteNumber
![]() |
DisplayWriteNumber |
Show a number ranging from 000 to 999 on the display. Number is printed vertically. | |
![]() |
Value |
Enter a number from 0 to 999. | |
![]() |
Return |
EEReadValue
![]() |
EEReadValue |
Retreives a value from none volitile memory | |
![]() |
Address |
Address to write to, Range: 0-255 | |
![]() |
Return |
EEStoreValue
![]() |
EEStoreValue |
Saves a value to none volitile memory | |
![]() |
Address |
Address to write to, Range: 0-255 | |
![]() |
Value |
Value to store, Range: 0-255 | |
![]() |
Return |
Initialise
![]() |
Initialise |
Initializes all present hardware and communication. Place this at the very start of your code. | |
![]() |
Return |
LedsWrite
![]() |
LedsWrite |
Set the button-leds. MSB = leftmost led LSB = rightmost led | |
![]() |
Value |
MSB = leftmost dot, LSB = rightmost dot | |
![]() |
Return |
MP3GetStatus
![]() |
MP3GetStatus |
Returns the status of the MP3 module. 0 = module in sleep 1 = track is playing 2 = track is pauzed 3 = track is stopped | |
![]() |
Return |
MP3PausePlayResetStop
![]() |
MP3PausePlayResetStop |
Allows the current playing track to be paused, restarted or stopped. | |
![]() |
Mode |
0=Pause, 1=Play, 2=Reset, 3=Stop | |
![]() |
Return |
MP3PlayTrack
MP3SendCommand
![]() |
MP3SendCommand |
Send commands to MP3 module. Check datasheet for info. | |
![]() |
Command |
![]() |
Para1 |
![]() |
Para2 |
![]() |
Return |
MP3SetVolume
![]() |
MP3SetVolume |
Sets the volume level for the MP3 module | |
![]() |
Volume |
Range: 0 (min) - 30 (max) | |
![]() |
Return |
PlayNote
PotRead
PwrLedSet
![]() |
PwrLedSet |
Control the PWR LED. 0 = red + green 1 = red 2 = green | |
![]() |
Value |
0 = red + green, 1 = red, 2 = green | |
![]() |
Return |
Property reference
![]() |
Properties |
![]() |
LED Colours |
![]() |
LED On |
![]() |
LED Off |
![]() |
Display Colours |
![]() |
On Colour |
![]() |
Off Colour |
![]() |
Background Colour |