├── doc ├── PropBASIC.odt └── PropBASIC.pdf ├── bin ├── 1-42 │ └── PropBasic.exe ├── 1-44 │ └── PropBasic.exe └── 1-48 │ └── PropBasic.exe ├── site.yml ├── .gitignore ├── example ├── Community Contributed Examples │ ├── Andre Nieuwoudt │ │ ├── I2C │ │ │ ├── I2C Library.docx │ │ │ ├── Libraries │ │ │ │ ├── I2C_LIB_SUBS.pbas │ │ │ │ ├── I2C_LIB_CODE.pbas │ │ │ │ └── I2C_LIB.pbas │ │ │ └── Sample Code │ │ │ │ └── I2C_Write_Read_Example.pbas │ │ ├── TX-RX │ │ │ ├── TX_RX Library.docx │ │ │ ├── Sample Code │ │ │ │ ├── TX_DEC & TX_DECX_Test.pbas │ │ │ │ ├── Blank_Template_Without_Task_Variable_TX_RX_Pins.pbas │ │ │ │ ├── Variable_BAUD_TX_RX_Pins_Example.pbas │ │ │ │ └── Blank_Template_With_Task_Variable_TX_RX_Pins.pbas │ │ │ └── Libraries │ │ │ │ └── TX_RX_LIB_SUBS.pbas │ │ ├── Utilities │ │ │ ├── Utilities Library.docx │ │ │ ├── Sample Code │ │ │ │ ├── NCD_Hight_Test.pbas │ │ │ │ ├── NCD_Low_Test.pbas │ │ │ │ ├── Set_Clear_Bit_Test.pbas │ │ │ │ ├── Get_Bit_Test.pbas │ │ │ │ ├── Invert_Bit_Test.pbas │ │ │ │ ├── Transpose Bits Test.pbas │ │ │ │ ├── PiezoX_Test.pbas │ │ │ │ ├── Freq_Out_Test.pbas │ │ │ │ ├── Put_Get_Nib_Test.pbas │ │ │ │ ├── Put_Get_Byte_Test.pbas │ │ │ │ ├── Put_Get_Bit_Test.pbas │ │ │ │ ├── Freq_OutX_Test.pbas │ │ │ │ ├── Piezo_Test.pbas │ │ │ │ ├── Copy_Byte_Test.pbas │ │ │ │ ├── Get_Digit_Test.pbas │ │ │ │ ├── Copy_Bit_Test.pbas │ │ │ │ ├── BUTTON_Test.pbas │ │ │ │ ├── Copy_Nib_Test.pbas │ │ │ │ ├── DCD_Bit_Test.pbas │ │ │ │ └── LOOKDOWN_LOOKUP_Test.pbas │ │ │ └── Libraries │ │ │ │ └── UTILS_LIB_SUBS.pbas │ │ ├── Multi-Dimensional Arrays │ │ │ ├── Multi-Dimensional Arrays.docx │ │ │ ├── Multi-Dimensional Arrays.xlsx │ │ │ ├── 2 Dimensional_Array V2.pbas │ │ │ ├── 3 Dimensional_Array V2.pbas │ │ │ └── 4 Dimensional_Array V2.pbas │ │ ├── Loading Code and Libraries │ │ │ ├── Loading Code and Libraries.docx │ │ │ ├── 2. Example_Load_Code_Into_Task.pbas │ │ │ ├── 1. Example_Load_Libraries_Into_Tasks.pbas │ │ │ └── TASK_Display_DS1302_Code.pbas │ │ ├── LCD Directly Connected │ │ │ ├── LCD Libraries Directly Connected.docx │ │ │ ├── Libraries │ │ │ │ └── LCD_DIRECT_LIB_SUBS.pbas │ │ │ └── Sample Code │ │ │ │ └── LCD_Test_STR_NUM_LIB.pbas │ │ ├── LCD Connected via IO Expander │ │ │ ├── LCD Libraries Connected via an IO Expander.docx │ │ │ ├── Sample Code │ │ │ │ ├── LCD2004 I2C LCD Interface - Layout Schematic.png │ │ │ │ └── LCD2004 I2C LCD Interface - Micro Robotics .docx │ │ │ └── Libraries │ │ │ │ └── LCD_EXPANDER_LIB_SUBS.pbas │ │ ├── PAUSE │ │ │ └── Libraries │ │ │ │ ├── DELAYS_LIB_SUBS.pbas │ │ │ │ ├── DELAYS_LIB.pbas │ │ │ │ └── DELAYS_LIB_CODE.pbas │ │ └── Program Templates │ │ │ ├── Blank_Template_Without_Task.pbas │ │ │ ├── Blank_Template_Without_Task_Variable_TX_RX_Pins.pbas │ │ │ ├── Example_Template_Without_Tasks.pbas │ │ │ ├── Blank_Template_With_Task.pbas │ │ │ └── Blank_Template_With_Task_Variable_TX_RX_Pins.pbas │ ├── readme.md │ └── JonnyMac │ │ ├── pstcodes.lib │ │ ├── delays.lib │ │ ├── one_wire.lib │ │ └── sircs.lib └── Ping.pbas ├── .travis ├── after_script.sh ├── install.sh └── script.sh ├── makefile ├── src ├── _LOOKUP.PAS ├── PropBasic.dof ├── _RCTIME.PAS ├── _RANDOM.PAS └── DEVICES.PAS ├── propbasic-compile.sh ├── packthing.yml ├── appveyor.yml ├── LICENSE ├── .travis.yml └── README.md /doc/PropBASIC.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parallaxinc/PropBASIC/HEAD/doc/PropBASIC.odt -------------------------------------------------------------------------------- /doc/PropBASIC.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parallaxinc/PropBASIC/HEAD/doc/PropBASIC.pdf -------------------------------------------------------------------------------- /bin/1-42/PropBasic.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parallaxinc/PropBASIC/HEAD/bin/1-42/PropBasic.exe -------------------------------------------------------------------------------- /bin/1-44/PropBasic.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parallaxinc/PropBASIC/HEAD/bin/1-44/PropBasic.exe -------------------------------------------------------------------------------- /bin/1-48/PropBasic.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parallaxinc/PropBASIC/HEAD/bin/1-48/PropBasic.exe -------------------------------------------------------------------------------- /site.yml: -------------------------------------------------------------------------------- 1 | type: compilers 2 | 3 | links: 4 | Manual: https://github.com/parallaxinc/PropBASIC/raw/master/doc/PropBASIC.pdf 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.ppu 3 | *.err 4 | *.spin 5 | *.binary 6 | *.compiled 7 | 8 | propbasic-*/ 9 | propbasic-*.tgz 10 | propbasic-*.zip 11 | 12 | *.swp 13 | *~ 14 | build/ 15 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/I2C/I2C Library.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parallaxinc/PropBASIC/HEAD/example/Community Contributed Examples/Andre Nieuwoudt/I2C/I2C Library.docx -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/TX-RX/TX_RX Library.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parallaxinc/PropBASIC/HEAD/example/Community Contributed Examples/Andre Nieuwoudt/TX-RX/TX_RX Library.docx -------------------------------------------------------------------------------- /.travis/after_script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | ls bin/* 5 | 6 | case "$PLATFORM" in 7 | "osx") 8 | ;; 9 | "linux") 10 | ;; 11 | *) 12 | echo "Invalid PLATFORM" 13 | exit 1 14 | ;; 15 | esac 16 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Utilities/Utilities Library.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parallaxinc/PropBASIC/HEAD/example/Community Contributed Examples/Andre Nieuwoudt/Utilities/Utilities Library.docx -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | all: 2 | 3 | linux: 4 | cd src; fpc -Tlinux -O3 PropBasic.lpr 5 | 6 | mac: 7 | cd src; fpc -Tdarwin -O3 PropBasic.lpr 8 | 9 | win: 10 | cd src; fpc -O3 PropBasic.lpr 11 | 12 | clean: 13 | cd src; rm -f *.o *.ppu PropBasic propbasic 14 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Multi-Dimensional Arrays/Multi-Dimensional Arrays.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parallaxinc/PropBASIC/HEAD/example/Community Contributed Examples/Andre Nieuwoudt/Multi-Dimensional Arrays/Multi-Dimensional Arrays.docx -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Multi-Dimensional Arrays/Multi-Dimensional Arrays.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parallaxinc/PropBASIC/HEAD/example/Community Contributed Examples/Andre Nieuwoudt/Multi-Dimensional Arrays/Multi-Dimensional Arrays.xlsx -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Loading Code and Libraries/Loading Code and Libraries.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parallaxinc/PropBASIC/HEAD/example/Community Contributed Examples/Andre Nieuwoudt/Loading Code and Libraries/Loading Code and Libraries.docx -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/LCD Directly Connected/LCD Libraries Directly Connected.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parallaxinc/PropBASIC/HEAD/example/Community Contributed Examples/Andre Nieuwoudt/LCD Directly Connected/LCD Libraries Directly Connected.docx -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/LCD Connected via IO Expander/LCD Libraries Connected via an IO Expander.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parallaxinc/PropBASIC/HEAD/example/Community Contributed Examples/Andre Nieuwoudt/LCD Connected via IO Expander/LCD Libraries Connected via an IO Expander.docx -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/LCD Connected via IO Expander/Sample Code/LCD2004 I2C LCD Interface - Layout Schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parallaxinc/PropBASIC/HEAD/example/Community Contributed Examples/Andre Nieuwoudt/LCD Connected via IO Expander/Sample Code/LCD2004 I2C LCD Interface - Layout Schematic.png -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/LCD Connected via IO Expander/Sample Code/LCD2004 I2C LCD Interface - Micro Robotics .docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parallaxinc/PropBASIC/HEAD/example/Community Contributed Examples/Andre Nieuwoudt/LCD Connected via IO Expander/Sample Code/LCD2004 I2C LCD Interface - Micro Robotics .docx -------------------------------------------------------------------------------- /src/_LOOKUP.PAS: -------------------------------------------------------------------------------- 1 | Unit _LOOKUP; 2 | 3 | {$MODE Delphi} 4 | 5 | // LMM Index 6 | 7 | Interface 8 | 9 | Uses GLOBAL; 10 | 11 | Procedure ProcessLookUp; 12 | Procedure ProcessLookDown; 13 | 14 | Implementation 15 | 16 | Procedure ProcessLookUp; 17 | Begin 18 | End; 19 | 20 | Procedure ProcessLookDown; 21 | Begin 22 | End; 23 | 24 | End. 25 | -------------------------------------------------------------------------------- /.travis/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | git submodule update --init --recursive 5 | 6 | case "$PLATFORM" in 7 | "osx") 8 | brew install fpc 9 | ;; 10 | "linux") 11 | sudo apt-get update 12 | sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes install fpc 13 | ;; 14 | *) 15 | echo "Invalid PLATFORM" 16 | exit 1 17 | ;; 18 | esac 19 | 20 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/readme.md: -------------------------------------------------------------------------------- 1 | Community Contributed Examples have been shared by community members of the Parallax Forum. 2 | 3 | http://forums.parallax.com 4 | 5 | Support for using these libraries cannot be provided by the author of PropBasic or Parallax Inc. 6 | The examples cannot be guaranteed to work for all users, but are shared in case they help in some way- at least as a starting point for new users. 7 | 8 | For help with PropBasic or these community examples, try posting a question over at the Parallax forums. -------------------------------------------------------------------------------- /propbasic-compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PBASFILE=$1 4 | 5 | if [ -z $PBASFILE ] ; then 6 | echo "Error: Must pass a file name!" 7 | exit 1 8 | fi 9 | 10 | propbasic ./$PBASFILE 11 | 12 | if [ $? -ne 0 ] ; then 13 | echo "Error: Failed to compile PropBASIC code" 14 | exit 1 15 | fi 16 | 17 | SPINFILE=${PBASFILE%.pbas}.spin 18 | BINFILE=`echo $SPINFILE | sed -e 's/.spin$//'` 19 | 20 | bstc -b $SPINFILE -o $BINFILE 21 | 22 | if [ $? -ne 0 ] ; then 23 | echo "Error: Failed to compile Spin code" 24 | exit 1 25 | fi 26 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/PAUSE/Libraries/DELAYS_LIB_SUBS.pbas: -------------------------------------------------------------------------------- 1 | ' ====================================================================== 2 | ' Delays Library for PropBASIC 3 | ' -- by Jon McPhalen 4 | ' -- 21 MAY 2010 5 | ' -- requires PropBASIC 0.98a or later 6 | ' ====================================================================== 7 | 8 | ' LOADing seperate SUBS and CODE files works in the Main Program as well as in Tasks 9 | 10 | DELAY_MS SUB 1 ' shell for PAUSE 11 | DELAY_US SUB 1 ' shell for PAUSEUS -------------------------------------------------------------------------------- /example/Community Contributed Examples/JonnyMac/pstcodes.lib: -------------------------------------------------------------------------------- 1 | ' Parallax Serial Terminal 2 | ' -- control codes 3 | 4 | HOME CON 1 5 | GOTOXY CON 2 6 | CRSRLF CON 3 7 | CRSRRT CON 4 8 | CRSRUP CON 5 9 | CRSRN CON 6 10 | BEEP CON 7 11 | BKSP CON 8 12 | TAB CON 9 13 | LF CON 10 14 | CLREOL CON 11 15 | CLRDN CON 12 16 | CR CON 13 17 | GOTOX CON 14 18 | GOTOY CON 15 19 | CLS CON 16 ' allow use in strings 20 | -------------------------------------------------------------------------------- /packthing.yml: -------------------------------------------------------------------------------- 1 | name: PropBASIC 2 | package: propbasic 3 | org: Parallax Inc. 4 | url: http://developer.parallax.com/propbasic/ 5 | maintainer: LameStation 6 | email: contact@lamestation.com 7 | copyright: 2009-2016 8 | license: MIT 9 | tagline: A Propeller BASIC compiler. 10 | description: PropBasic is a BASIC compiler for the Parallax(c) Propeller microcontroller. 11 | master: propbasic 12 | 13 | target: 14 | deb: 15 | depends: 16 | section: 17 | categories: 18 | 19 | repos: 20 | propbasic: 21 | url: https://github.com/parallaxinc/PropBasic.git 22 | branch: master 23 | builder: fpc 24 | root: src 25 | -------------------------------------------------------------------------------- /.travis/script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | BUILD_VERSION="0.0.0" 5 | if [[ -n "$TRAVIS_TAG" ]] 6 | then 7 | BUILD_VERSION="$TRAVIS_TAG" 8 | fi 9 | 10 | BUILD_DIR="propbasic-$BUILD_VERSION-$PLATFORM" 11 | 12 | # build executable 13 | 14 | pushd src/ 15 | 16 | rm -f *.o *.ppu propbasic PropBasic 17 | 18 | case "$PLATFORM" in 19 | "osx") 20 | fpc -Tdarwin -opropbasic PropBasic.lpr 21 | ;; 22 | "linux") 23 | fpc -Tlinux -opropbasic PropBasic.lpr 24 | ;; 25 | *) 26 | echo "Invalid PLATFORM" 27 | exit 1 28 | ;; 29 | esac 30 | popd 31 | 32 | # copy resources 33 | 34 | rm -rf $BUILD_DIR 35 | mkdir -p $BUILD_DIR 36 | 37 | cp -f src/propbasic $BUILD_DIR 38 | cp -f doc/* $BUILD_DIR 39 | 40 | tar cvzf $BUILD_DIR.tgz $BUILD_DIR 41 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/I2C/Libraries/I2C_LIB_SUBS.pbas: -------------------------------------------------------------------------------- 1 | 2 | ' LOADing seperate SUBS and CODE files works in the Main Program as well as in Tasks 3 | 4 | '*********************************************************************************************************************** 5 | ' 6 | ' 7 | '*********************************************************************************************************************** 8 | 9 | I2C_In FUNC 1 ' If _param1 = 1 then Read 1 Byte. If _param1 = 2 then Read 2 Bytes (Word). 10 | I2C_Out SUB 2 ' __param1 = Data to Write. If _param2 = 1 then Write 1 Byte. If _param2 = 2 then Write 2 Bytes (Word). 11 | 12 | I2C_START SUB 0 13 | I2C_READ FUNC 1 14 | I2C_WRITE SUB 1 15 | I2C_STOP SUB 0 16 | I2C_ADDRESS SUB 0 -------------------------------------------------------------------------------- /example/Ping.pbas: -------------------------------------------------------------------------------- 1 | ' This program reads the distance from a PING sensor connected to pin 2. 2 | ' Converts the value to tenths of inches and sends the distance to the PC. 3 | ' 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | FREQ 80_000_000 6 | 7 | Baud CON "T115200" ' Baud rate to communicate with PC 8 | 9 | PingPin PIN 2 LOW ' Connected to Sig pin on Ping module 10 | TX PIN 30 HIGH ' Send data back to PC 11 | 12 | value VAR LONG 13 | 14 | Message DATA "Distance is " 15 | valueStr DATA "1234.5 inches.", 13, 0 16 | 17 | PROGRAM Start 18 | 19 | Start: 20 | DO 21 | PAUSE 10 22 | PULSOUT PingPin, 5 ' Trigger PING 23 | PAUSEUS 5 24 | PULSIN PingPin, 1, value ' Measure PING pulse 25 | value = value ** 291200017 ' Convert to tenths of inches (multiply by 0.0678002873901278) 26 | valueStr = STR value, 5, 5 ' Convert value to ASCII 27 | RDBYTE valueStr(4), value ' Insert decimal point 28 | WRBYTE valueStr(4), ".", value 29 | SEROUT TX, Baud, Message 30 | LOOP 31 | END 32 | 33 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/JonnyMac/delays.lib: -------------------------------------------------------------------------------- 1 | ' ====================================================================== 2 | ' Delays Library for PropBASIC 3 | ' -- by Jon McPhalen 4 | ' -- 21 MAY 2010 5 | ' -- requires PropBASIC 0.98a or later 6 | ' ====================================================================== 7 | 8 | DELAY_MS SUB 1 ' shell for PAUSE 9 | DELAY_US SUB 1 ' shell for PAUSEUS 10 | 11 | 12 | ' ---------------------------------------------------------------------- 13 | '{$CODE} 14 | ' ---------------------------------------------------------------------- 15 | 16 | ' Use: DELAY_MS duration 17 | ' -- shell for PAUSE 18 | 19 | '{$IFUSED DELAY_MS} 20 | SUB DELAY_MS 21 | 22 | PAUSE __param1 23 | 24 | ENDSUB 25 | '{$ENDIF} 26 | 27 | ' ---------------------------------------------------------------------- 28 | 29 | ' Use: DELAY_US duration 30 | ' -- shell for PAUSEUS 31 | 32 | '{$IFUSED DELAY_US} 33 | SUB DELAY_US 34 | 35 | PAUSEUS __param1 36 | 37 | ENDSUB 38 | '{$ENDIF} 39 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/PAUSE/Libraries/DELAYS_LIB.pbas: -------------------------------------------------------------------------------- 1 | ' ====================================================================== 2 | ' Delays Library for PropBASIC 3 | ' -- by Jon McPhalen 4 | ' -- 21 MAY 2010 5 | ' -- requires PropBASIC 0.98a or later 6 | ' ====================================================================== 7 | 8 | DELAY_MS SUB 1 ' shell for PAUSE 9 | DELAY_US SUB 1 ' shell for PAUSEUS 10 | 11 | 12 | ' ---------------------------------------------------------------------- 13 | '{$CODE} 14 | ' ---------------------------------------------------------------------- 15 | 16 | ' Use: DELAY_MS duration 17 | ' -- shell for PAUSE 18 | 19 | '{$IFUSED DELAY_MS} 20 | SUB DELAY_MS 21 | 22 | PAUSE __param1 23 | 24 | ENDSUB 25 | '{$ENDIF} 26 | 27 | ' ---------------------------------------------------------------------- 28 | 29 | ' Use: DELAY_US duration 30 | ' -- shell for PAUSEUS 31 | 32 | '{$IFUSED DELAY_US} 33 | SUB DELAY_US 34 | 35 | PAUSEUS __param1 36 | 37 | ENDSUB 38 | '{$ENDIF} 39 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | clone_depth: 200 2 | 3 | configuration: Release 4 | 5 | install: 6 | - git submodule update --init --recursive 7 | - choco install -y 7zip 8 | - set PATH=%PATH%;"C:\Program Files\7-Zip" 9 | - curl -o "C:\FPC.zip" "http://lamestation.net/downloads/appveyor/FPC.zip" 10 | - 7z x "C:\FPC.zip" -o"C:\" 11 | - set PATH=%PATH%;"C:\FPC\3.0.0\bin\i386-win32" 12 | - if defined APPVEYOR_REPO_TAG_NAME set BUILD_VERSION=%APPVEYOR_REPO_TAG_NAME% 13 | - if not defined APPVEYOR_REPO_TAG_NAME set BUILD_VERSION="0.0.0" 14 | - set BUILD_DIR="propbasic-%BUILD_VERSION%-win32.zip" 15 | 16 | build_script: 17 | - cd src/ 18 | - fpc -Twin32 -opropbasic PropBasic.lpr 19 | - cd .. 20 | - mkdir %BUILD_DIR% 21 | - cp src\propbasic %BUILD_DIR% 22 | - cp doc\PropBASIC.pdf %BUILD_DIR% 23 | - 7z a %BUILD_DIR% %BUILD_DIR% 24 | 25 | artifacts: 26 | - path: propbasic-*.zip 27 | name: propbasic 28 | 29 | deploy: 30 | provider: GitHub 31 | auth_token: 32 | secure: agKPOOVVpPx6LVzUWLOuktBrZ7NKeUbyvqwNHjw2FsrAyCbgiq/Ha+CmkoZdCVJF 33 | draft: false 34 | prerelease: false 35 | on: 36 | appveyor_repo_tag: true 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Parallax Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/PAUSE/Libraries/DELAYS_LIB_CODE.pbas: -------------------------------------------------------------------------------- 1 | ' ====================================================================== 2 | ' Delays Library for PropBASIC 3 | ' -- by Jon McPhalen 4 | ' -- 21 MAY 2010 5 | ' -- requires PropBASIC 0.98a or later 6 | ' ====================================================================== 7 | 8 | ' !!! The {$CODE} Command does NOT work when splittng the SUBS and the CODE !!!!! 9 | ' The {$CODE} Command ONLY works if you "LOAD" the Complete File (inluding the SUBS) in the Main Program 10 | ' 11 | ' LOADing seperate SUBS and CODE files works in the Main Program as well as in Tasks 12 | ' 13 | ' ' ---------------------------------------------------------------------- 14 | ' '{$CODE} 15 | ' ' ---------------------------------------------------------------------- 16 | 17 | ' Use: DELAY_MS duration 18 | ' -- shell for PAUSE 19 | 20 | '{$IFUSED DELAY_MS} 21 | SUB DELAY_MS 22 | 23 | PAUSE __param1 24 | 25 | ENDSUB 26 | '{$ENDIF} 27 | 28 | ' ---------------------------------------------------------------------- 29 | 30 | ' Use: DELAY_US duration 31 | ' -- shell for PAUSEUS 32 | 33 | '{$IFUSED DELAY_US} 34 | SUB DELAY_US 35 | 36 | PAUSEUS __param1 37 | 38 | ENDSUB 39 | '{$ENDIF} 40 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | dist: trusty 3 | cache: apt 4 | language: cpp 5 | addons: 6 | apt: 7 | packages: 8 | - fpc 9 | matrix: 10 | include: 11 | - os: osx 12 | env: PLATFORM=osx 13 | - os: linux 14 | env: PLATFORM=linux 15 | install: "./.travis/install.sh" 16 | script: "./.travis/script.sh" 17 | after_script: "./.travis/after_script.sh" 18 | deploy: 19 | provider: releases 20 | api_key: 21 | secure: nwyk7u7fArM/xWoYN6PejkQgEcqc1uIjGqbSlqRK8fPNM1099/iRaM3S470wGYhZga2VTXW26JzMwBWyPN/TIHHfSbNVbt77kWEvTJeK8X5Yofng1k1xhrzLZNM0Du2Ni63qYY2w/Pfg4yVz2XoJCWb1zgqHwBxnStUw8O+bou/M+RKoQaP61a71MQtiXypcEdQ6NPq2nItgptpJMJh3K8SUaA9wsCyflgT1REWcFKL+YLSVAR0SYVlaeRI7D+fOnlsRgbu3wAN4C3QtHFB26LtOH1rRmJLfVV7o9+VV9nKQXRZLRKGYDGrYua+9ev4IcEsipsBP4JEjXxZAqw0225z+H8khm6GwjPYlRmxLgQDtWbdoDu2+fFYPlI8gJzfQ+hz2ZCrWjPy2nAV1VYKiUfFChkPHLu3ooX76X1lEjqled2OiXyMdkRL6JrIzWcjRv+c7MHJlxIUeF0m7PIIFe6f1/6o8tBFMZZdAMY5ELa3sjDzMY9osn3fx43ZIiZ14NyItwNmMFbmURLPioLlQ47lo0v1tR1l/JFKV+eUXA9xrDEpSXio45Ldi2LE9QUAKwvLy+AXK9KrpMxdVk88dbm2R6sADDegOgGFPnw2IlgMbFPzDZI8FWVHue2mKSYhh2fNDl7H62zKuVk2pleHcKic/b8LUUaNarWTH3Jd3lPo= 22 | file_glob: true 23 | file: propbasic-*.tgz 24 | skip_cleanup: true 25 | on: 26 | repo: parallaxinc/PropBASIC 27 | tags: true 28 | all_branches: true 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PropBASIC 2 | 3 | PropBasic is a BASIC compiler for the Parallax(c) Propeller microcontroller. It translates program code written in the 4 | BASIC computer language into Propeller assembly language instructions. 5 | 6 | 7 | ## Build Instructions 8 | 9 | Down a source tarball or archive, or check out with git. 10 | 11 | git clone https://github.com/parallaxinc/PropBASIC 12 | 13 | ### Mac 14 | 15 | 1. Download and install [Homebrew](http://brew.sh/). 16 | 2. Open a terminal and run `$ brew install fpc` 17 | 3. `cd` to the directory where you unpacked PropBASIC. 18 | 4. Run `fpc -Tdarwin -opropbasic PropBasic.lpr` to build. An executable named `propbasic` will be created. 19 | 20 | ### Linux 21 | 22 | 1. Open a terminal and run `$ apt-get install fpc` on Debian, or `$ yum install fpc` on RedHat. 23 | 3. `cd` to the directory where you unpacked PropBASIC. 24 | 4. Run `fpc -Tlinux -opropbasic PropBasic.lpr` to build. An executable named `propbasic` will be created. 25 | 26 | ### Windows 27 | 28 | 1. Go to [freepascal.org](http://www.freepascal.org/) and download/install the latest version. 29 | 2. Add `"C:\FPC\3.0.0\bin\i386-win32"` to the system path. 30 | 3. Open PowerShell and `cd to the directory where you unpacked PropBASIC. 31 | 4. Run `fpc -Twin32 -opropbasic PropBasic.lpr` to build. An executable named `propbasic.exe` will be created. 32 | 33 | 34 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/LCD Directly Connected/Libraries/LCD_DIRECT_LIB_SUBS.pbas: -------------------------------------------------------------------------------- 1 | 2 | ' LOADing seperate SUBS and CODE files works in the Main Program as well as in Tasks 3 | 4 | ' ************************************************************************************************************** 5 | ' NOTE: The Main Program MUST contain this Variable because it is used by this Library 6 | 7 | ' LCD_Data VAR LONG ' Data sent by Main Program to LCD. 8 | 9 | ' ************************************************************************************************************** 10 | 11 | 12 | ' Pin Mapping 13 | ' LCD_BL PIN 0 14 | ' LCD_RS PIN 1 15 | ' LCD_RW PIN X ' LCD Read/Write - Connected directly to Ground because we are not reading from the LCD 16 | ' LCD_E PIN 2 17 | 18 | ' LCD_DB4 PIN 3 19 | ' LCD_DB5 PIN 4 20 | ' LCD_DB6 PIN 5 21 | ' LCD_DB7 PIN 6 22 | 23 | ' LCD_BUS PIN 6.. 3 OUTPUT ' !!! The Pins must be in MSB to LSB Order. 4-bit LCD Data Bus PIN Group 24 | 25 | 26 | LCD_INIT SUB 0 ' Initialise the LCD in 4-BIT Mode 27 | LCD_CMD SUB 1 ' Send Command Code to LCD 28 | LCD_BYTE SUB 1 ' Write a Byte to the LCD 29 | LCD_STR SUB 1, 2 ' Write a String to the LCD 30 | LCD_DEC SUB 2 ' Write a Number to the LCD - No Leading Spaces, No Leading Zeroes 31 | LCD_DECLZ SUB 2 ' Write a Number to the LCD with Leading Zeroes 32 | LCD_DECLS SUB 2 ' Write a Number to the LCD withLeading Spaces 33 | LCD_Get_Digit FUNC 2 ' Used by LCD_DEC, LCD_DECLZ and LCD_DECLZ 34 | LCD_ON SUB 0 ' Turn LCD and Backlight ON 35 | LCD_OFF SUB 0 ' Turn LCD and Backlight OFF 36 | LCD_CLEAR SUB 0 ' Clear LCD Screen -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/TX-RX/Sample Code/TX_DEC & TX_DECX_Test.pbas: -------------------------------------------------------------------------------- 1 | 2 | DEVICE P8X32A, XTAL1, PLL16X 3 | XIN 5_000_000 4 | 5 | ' ---------------------------------------------------------------------- 6 | ' I/O Pins 7 | ' ---------------------------------------------------------------------- 8 | ' X_PIN PIN 31 INPUT 9 | TX_PIN PIN 30 INPUT 10 | 11 | 12 | 13 | ' ---------------------------------------------------------------------- 14 | ' Constants 15 | ' ---------------------------------------------------------------------- 16 | Terminal_Baud CON 115200 17 | 18 | 19 | 20 | ' -- TX_Format Constants & Variables --------------- 21 | HOME CON 1 22 | GOTOXY CON 2 23 | BKSP CON 8 24 | TAB CON 9 25 | LF CON 10 26 | CLREOL CON 11 27 | CLRDN CON 12 28 | CR CON 13 29 | GOTOX CON 14 30 | GOTOY CON 15 31 | CLS CON 16 32 | 33 | 34 | 35 | ' ---------------------------------------------------------------------- 36 | ' Data 37 | ' ---------------------------------------------------------------------- 38 | 39 | 40 | ' ---------------------------------------------------------------------- 41 | ' Variables 42 | ' ---------------------------------------------------------------------- 43 | TX_BAUD VAR LONG 44 | 45 | Temp VAR LONG 46 | Temp2 VAR LONG 47 | 48 | 49 | ' ---------------------------------------------------------------------- 50 | ' SUB & FUNC Definitions 51 | ' ---------------------------------------------------------------------- 52 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB.pbas" 53 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 54 | 55 | 56 | ' ---------------------------------------------------------------------- 57 | ' TASK Definitions 58 | ' ---------------------------------------------------------------------- 59 | 60 | ' ====================================================================== 61 | PROGRAM START 62 | ' ====================================================================== 63 | 64 | START: 65 | 66 | TX_BAUD = Terminal_Baud 67 | 68 | PAUSE 5000 69 | TX_BYTE CLS 70 | 71 | Temp = 123_456_789 72 | 73 | TX_STR "DEC " 74 | TX_DEC Temp 75 | TX_BYTE CR 76 | TX_STR "DECX " 77 | TX_DECX Temp, 12 ' Display 12 Digits padded with leading zeroes 78 | TX_BYTE CR 79 | TX_STR "DECX " 80 | TX_DECX Temp, 3 ' Display 3 Digits. Leading digits are truncated 81 | 82 | 83 | 84 | END 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /src/PropBasic.dof: -------------------------------------------------------------------------------- 1 | [FileVersion] 2 | Version=7.0 3 | [Compiler] 4 | A=8 5 | B=0 6 | C=1 7 | D=1 8 | E=0 9 | F=0 10 | G=1 11 | H=1 12 | I=1 13 | J=0 14 | K=0 15 | L=1 16 | M=0 17 | N=1 18 | O=1 19 | P=1 20 | Q=0 21 | R=0 22 | S=0 23 | T=0 24 | U=0 25 | V=1 26 | W=0 27 | X=1 28 | Y=1 29 | Z=1 30 | ShowHints=1 31 | ShowWarnings=1 32 | UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; 33 | NamespacePrefix= 34 | SymbolDeprecated=1 35 | SymbolLibrary=1 36 | SymbolPlatform=1 37 | UnitLibrary=1 38 | UnitPlatform=1 39 | UnitDeprecated=1 40 | HResultCompat=1 41 | HidingMember=1 42 | HiddenVirtual=1 43 | Garbage=1 44 | BoundsError=1 45 | ZeroNilCompat=1 46 | StringConstTruncated=1 47 | ForLoopVarVarPar=1 48 | TypedConstVarPar=1 49 | AsgToTypedConst=1 50 | CaseLabelRange=1 51 | ForVariable=1 52 | ConstructingAbstract=1 53 | ComparisonFalse=1 54 | ComparisonTrue=1 55 | ComparingSignedUnsigned=1 56 | CombiningSignedUnsigned=1 57 | UnsupportedConstruct=1 58 | FileOpen=1 59 | FileOpenUnitSrc=1 60 | BadGlobalSymbol=1 61 | DuplicateConstructorDestructor=1 62 | InvalidDirective=1 63 | PackageNoLink=1 64 | PackageThreadVar=1 65 | ImplicitImport=1 66 | HPPEMITIgnored=1 67 | NoRetVal=1 68 | UseBeforeDef=1 69 | ForLoopVarUndef=1 70 | UnitNameMismatch=1 71 | NoCFGFileFound=1 72 | MessageDirective=1 73 | ImplicitVariants=1 74 | UnicodeToLocale=1 75 | LocaleToUnicode=1 76 | ImagebaseMultiple=1 77 | SuspiciousTypecast=1 78 | PrivatePropAccessor=1 79 | UnsafeType=0 80 | UnsafeCode=0 81 | UnsafeCast=0 82 | [Linker] 83 | MapFile=0 84 | OutputObjs=0 85 | ConsoleApp=1 86 | DebugInfo=0 87 | RemoteSymbols=0 88 | MinStackSize=16384 89 | MaxStackSize=1048576 90 | ImageBase=4194304 91 | ExeDescription= 92 | [Directories] 93 | OutputDir= 94 | UnitOutputDir= 95 | PackageDLLOutputDir= 96 | PackageDCPOutputDir= 97 | SearchPath= 98 | Packages= 99 | Conditionals= 100 | DebugSourceDirs= 101 | UsePackages=0 102 | [Parameters] 103 | RunParams="E:\PropBasic\test.pbas" /p /e 104 | HostApplication= 105 | Launcher= 106 | UseLauncher=0 107 | DebugCWD= 108 | [Version Info] 109 | IncludeVerInfo=0 110 | AutoIncBuild=0 111 | MajorVer=1 112 | MinorVer=0 113 | Release=0 114 | Build=0 115 | Debug=0 116 | PreRelease=0 117 | Special=0 118 | Private=0 119 | DLL=0 120 | Locale=1033 121 | CodePage=1252 122 | [Version Info Keys] 123 | CompanyName= 124 | FileDescription= 125 | FileVersion=1.0.0.0 126 | InternalName= 127 | LegalCopyright= 128 | LegalTrademarks= 129 | OriginalFilename= 130 | ProductName= 131 | ProductVersion=1.0.0.0 132 | Comments= 133 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Utilities/Sample Code/NCD_Hight_Test.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ---------------------------------------------------------------------- 8 | ' GLOBAL: I/O Pins 9 | ' ---------------------------------------------------------------------- 10 | TX_PIN PIN 30 INPUT 11 | 12 | ' ---------------------------------------------------------------------- 13 | ' GLOBAL: Constants 14 | ' ---------------------------------------------------------------------- 15 | Terminal_Baud CON 115200 16 | 17 | ' ---------------------------------------------------------------------- 18 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 19 | ' ---------------------------------------------------------------------- 20 | 21 | 22 | ' ---------------------------------------------------------------------- 23 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 24 | ' ---------------------------------------------------------------------- 25 | 26 | 27 | ' ---------------------------------------------------------------------- 28 | ' COG 0: Variables (Long only) 29 | ' ---------------------------------------------------------------------- 30 | TX_BAUD VAR LONG 31 | 32 | Row_Code VAR Long 33 | 34 | ' ---------------------------------------------------------------------- 35 | ' COG 0: SUB & FUNC Definitions 36 | ' ---------------------------------------------------------------------- 37 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 38 | LOAD "D:\Propeller\Propeller Programs\Libraries\UTILS_LIB.pbas" 39 | 40 | 41 | ' ---------------------------------------------------------------------- 42 | ' TASK Definitions 43 | ' ---------------------------------------------------------------------- 44 | 45 | 46 | ' ====================================================================== 47 | PROGRAM START 48 | ' ====================================================================== 49 | 50 | START: 51 | 52 | TX_BAUD = Terminal_Baud 53 | PAUSE 5000 54 | SEROUT TX_PIN, T115200, 16 55 | 56 | 57 | Main: 58 | 59 | Row_Code = %1000_0000_0000_0000_1000_1000_1000_0010 60 | ' Row_Code = %1000_0000_0000_0000_0000_0000_0000_0001 61 | ' Row_Code = %0000_0000_0000_0000_0000_0000_0000_0001 62 | 63 | TX_STR "Binary String : " 64 | TX_BIN Row_Code, 32 65 | TX_BYTE 13 66 | 67 | Row_Code = NCD_High Row_Code 68 | 69 | TX_STR "Highest Bit# which is Set : " 70 | TX_DEC Row_Code 71 | TX_BYTE 13 72 | TX_BYTE 13 73 | 74 | 75 | 76 | 77 | END 78 | 79 | ' ---------------------------------------------------------------------- 80 | ' COG 0: SUB & FUNC Code 81 | ' ---------------------------------------------------------------------- 82 | 83 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Program Templates/Blank_Template_Without_Task.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' GLOBAL: Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ---------------------------------------------------------------------- 8 | ' GLOBAL: I/O Pins 9 | ' ---------------------------------------------------------------------- 10 | TX_PIN PIN 30 INPUT 11 | RX_PIN PIN 31 INPUT 12 | 13 | Speaker PIN 1 OUTPUT 14 | 15 | ' ---------------------------------------------------------------------- 16 | ' GLOBAL: Constants 17 | ' ---------------------------------------------------------------------- 18 | ' -- !!! You HAVE TO use Variables for the BAUD Rate/s 19 | Terminal_Baud CON 115200 20 | 21 | ' -- "TX_RX_Format_Lib_.pbas" Constants --------------- 22 | HOME CON 1 23 | CR CON 13 24 | CLS CON 16 25 | 26 | ' ---------------------------------------------------------------------- 27 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 28 | ' ---------------------------------------------------------------------- 29 | 30 | 31 | ' ---------------------------------------------------------------------- 32 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 33 | ' ---------------------------------------------------------------------- 34 | 35 | 36 | ' ---------------------------------------------------------------------- 37 | ' COG 0: Variables (Long only) 38 | ' ---------------------------------------------------------------------- 39 | TX_BAUD VAR LONG 40 | RX_BAUD VAR LONG 41 | 42 | ' ---------------------------------------------------------------------- 43 | ' COG 0: SUB & FUNC Definitions 44 | ' ---------------------------------------------------------------------- 45 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB.pbas" 46 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 47 | LOAD "D:\Propeller\Propeller Programs\Libraries\I2C_LIB.pbas" 48 | LOAD "D:\Propeller\Propeller Programs\Libraries\UTILS_LIB.pbas" 49 | 50 | 51 | 52 | ' ---------------------------------------------------------------------- 53 | ' TASK Definitions 54 | ' ---------------------------------------------------------------------- 55 | 56 | 57 | ' ====================================================================== 58 | PROGRAM START 59 | ' ====================================================================== 60 | 61 | START: 62 | 63 | TX_BAUD = Terminal_Baud 64 | RX_BAUD = Terminal_Baud 65 | 66 | DELAY_MS 5000 67 | TX_BYTE CLS 68 | 69 | 70 | END 71 | 72 | 73 | ' ---------------------------------------------------------------------- 74 | ' COG 0: SUB & FUNC Code 75 | ' ---------------------------------------------------------------------- 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Utilities/Sample Code/NCD_Low_Test.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ---------------------------------------------------------------------- 8 | ' GLOBAL: I/O Pins 9 | ' ---------------------------------------------------------------------- 10 | TX_PIN PIN 30 INPUT 11 | 12 | ' ---------------------------------------------------------------------- 13 | ' GLOBAL: Constants 14 | ' ---------------------------------------------------------------------- 15 | Terminal_Baud CON 115200 16 | 17 | ' ---------------------------------------------------------------------- 18 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 19 | ' ---------------------------------------------------------------------- 20 | 21 | 22 | ' ---------------------------------------------------------------------- 23 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 24 | ' ---------------------------------------------------------------------- 25 | 26 | 27 | ' ---------------------------------------------------------------------- 28 | ' COG 0: Variables (Long only) 29 | ' ---------------------------------------------------------------------- 30 | TX_BAUD VAR LONG 31 | 32 | Row_Code VAR Long 33 | 34 | ' ---------------------------------------------------------------------- 35 | ' COG 0: SUB & FUNC Definitions 36 | ' ---------------------------------------------------------------------- 37 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 38 | LOAD "D:\Propeller\Propeller Programs\Libraries\UTILS_LIB.pbas" 39 | 40 | 41 | ' ---------------------------------------------------------------------- 42 | ' TASK Definitions 43 | ' ---------------------------------------------------------------------- 44 | 45 | 46 | ' ====================================================================== 47 | PROGRAM START 48 | ' ====================================================================== 49 | 50 | START: 51 | 52 | TX_BAUD = Terminal_Baud 53 | PAUSE 5000 54 | SEROUT TX_PIN, T115200, 16 55 | 56 | 57 | Main: 58 | 59 | ' Row_Code = %1000_0000_0000_0000_1000_1000_1000_0010 60 | Row_Code = %1000_0000_0000_0000_0000_0000_0000_0000 61 | ' Row_Code = %0000_0000_1111_0000_0000_0000_1000_0000 62 | ' Row_Code = %0000_0000_0000_0000_0000_0000_0000_0010 63 | 64 | TX_STR "Binary String : " 65 | TX_BIN Row_Code, 32 66 | TX_BYTE 13 67 | 68 | Row_Code = NCD_Low Row_Code 69 | 70 | TX_STR "Lowest Bit# which is Set : " 71 | TX_DEC Row_Code 72 | TX_BYTE 13 73 | TX_BYTE 13 74 | 75 | 76 | 77 | 78 | END 79 | 80 | ' ---------------------------------------------------------------------- 81 | ' COG 0: SUB & FUNC Code 82 | ' ---------------------------------------------------------------------- 83 | 84 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Utilities/Sample Code/Set_Clear_Bit_Test.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ---------------------------------------------------------------------- 8 | ' GLOBAL: I/O Pins 9 | ' ---------------------------------------------------------------------- 10 | TX_PIN PIN 30 INPUT 11 | 12 | ' ---------------------------------------------------------------------- 13 | ' GLOBAL: Constants 14 | ' ---------------------------------------------------------------------- 15 | Terminal_Baud CON 115200 16 | 17 | ' ---------------------------------------------------------------------- 18 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 19 | ' ---------------------------------------------------------------------- 20 | 21 | 22 | ' ---------------------------------------------------------------------- 23 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 24 | ' ---------------------------------------------------------------------- 25 | 26 | 27 | ' ---------------------------------------------------------------------- 28 | ' COG 0: Variables (Long only) 29 | ' ---------------------------------------------------------------------- 30 | TX_BAUD VAR LONG 31 | 32 | Row_Code VAR Long 33 | Temp VAR Long 34 | Bit_Number VAR Long 35 | 36 | ' ---------------------------------------------------------------------- 37 | ' COG 0: SUB & FUNC Definitions 38 | ' ---------------------------------------------------------------------- 39 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 40 | LOAD "D:\Propeller\Propeller Programs\Libraries\UTILS_LIB.pbas" 41 | 42 | ' ---------------------------------------------------------------------- 43 | ' TASK Definitions 44 | ' ---------------------------------------------------------------------- 45 | 46 | 47 | ' ====================================================================== 48 | PROGRAM START 49 | ' ====================================================================== 50 | 51 | START: 52 | 53 | TX_BAUD = Terminal_Baud 54 | PAUSE 5000 55 | TX_BYTE 16 56 | 57 | 58 | Main: 59 | 60 | 61 | ' 1). Get the value of a Specific Bit Number from a Variable. The value of the Bit is returned in Bit number 0!. 62 | 63 | Row_Code = 0 ' %10101011 64 | Bit_Number = 0 65 | 66 | TX_STR "Bit Number : " 67 | TX_DEC Bit_Number 68 | TX_BYTE 13 69 | TX_STR "Variable : " 70 | TX_BIN Row_Code, 16 71 | TX_BYTE 13 72 | 73 | Temp = Set_Bit Row_Code, Bit_Number 74 | 75 | TX_STR "Bit Value : " 76 | TX_BIN Temp, 16 77 | TX_BYTE 13 78 | TX_BYTE 13 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | END 87 | 88 | ' ---------------------------------------------------------------------- 89 | ' COG 0: SUB & FUNC Code 90 | ' ---------------------------------------------------------------------- 91 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Utilities/Sample Code/Get_Bit_Test.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ---------------------------------------------------------------------- 8 | ' GLOBAL: I/O Pins 9 | ' ---------------------------------------------------------------------- 10 | TX_PIN PIN 30 INPUT 11 | 12 | ' ---------------------------------------------------------------------- 13 | ' GLOBAL: Constants 14 | ' ---------------------------------------------------------------------- 15 | Terminal_Baud CON 115200 16 | 17 | ' ---------------------------------------------------------------------- 18 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 19 | ' ---------------------------------------------------------------------- 20 | 21 | 22 | ' ---------------------------------------------------------------------- 23 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 24 | ' ---------------------------------------------------------------------- 25 | 26 | 27 | ' ---------------------------------------------------------------------- 28 | ' COG 0: Variables (Long only) 29 | ' ---------------------------------------------------------------------- 30 | TX_BAUD VAR LONG 31 | 32 | Row_Code VAR Long 33 | Temp VAR Long 34 | Bit_Number VAR Long 35 | 36 | ' ---------------------------------------------------------------------- 37 | ' COG 0: SUB & FUNC Definitions 38 | ' ---------------------------------------------------------------------- 39 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 40 | LOAD "D:\Propeller\Propeller Programs\Libraries\UTILS_LIB.pbas" 41 | 42 | ' ---------------------------------------------------------------------- 43 | ' TASK Definitions 44 | ' ---------------------------------------------------------------------- 45 | 46 | 47 | ' ====================================================================== 48 | PROGRAM START 49 | ' ====================================================================== 50 | 51 | START: 52 | 53 | TX_BAUD = Terminal_Baud 54 | PAUSE 5000 55 | SEROUT TX_PIN, T115200, 16 56 | 57 | 58 | Main: 59 | 60 | 61 | ' 1). Get the value of a Specific Bit Number from a Variable. The value of the Bit is returned in Bit number 0!. 62 | 63 | Row_Code = %10101011 64 | Bit_Number = 4 65 | 66 | TX_STR "Bit Number : " 67 | TX_DEC Bit_Number 68 | TX_BYTE 13 69 | TX_STR "Variable : " 70 | TX_BIN Row_Code, 16 71 | TX_BYTE 13 72 | 73 | Temp = Get_Bit Row_Code, Bit_Number 74 | 75 | TX_STR "Bit Value : " 76 | TX_BIN Temp, 16 77 | TX_BYTE 13 78 | TX_BYTE 13 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | END 87 | 88 | ' ---------------------------------------------------------------------- 89 | ' COG 0: SUB & FUNC Code 90 | ' ---------------------------------------------------------------------- 91 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Utilities/Sample Code/Invert_Bit_Test.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ---------------------------------------------------------------------- 8 | ' GLOBAL: I/O Pins 9 | ' ---------------------------------------------------------------------- 10 | TX_PIN PIN 30 INPUT 11 | 12 | ' ---------------------------------------------------------------------- 13 | ' GLOBAL: Constants 14 | ' ---------------------------------------------------------------------- 15 | Terminal_Baud CON 115200 16 | 17 | ' ---------------------------------------------------------------------- 18 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 19 | ' ---------------------------------------------------------------------- 20 | 21 | 22 | ' ---------------------------------------------------------------------- 23 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 24 | ' ---------------------------------------------------------------------- 25 | 26 | 27 | ' ---------------------------------------------------------------------- 28 | ' COG 0: Variables (Long only) 29 | ' ---------------------------------------------------------------------- 30 | TX_BAUD VAR LONG 31 | 32 | Temp VAR Long 33 | 34 | Value VAR Long 35 | 36 | Counter VAR LONG 37 | 38 | 39 | 40 | 41 | ' ---------------------------------------------------------------------- 42 | ' COG 0: SUB & FUNC Definitions 43 | ' ---------------------------------------------------------------------- 44 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 45 | LOAD "D:\Propeller\Propeller Programs\Libraries\UTILS_LIB.pbas" 46 | 47 | 48 | 49 | ' ---------------------------------------------------------------------- 50 | ' TASK Definitions 51 | ' ---------------------------------------------------------------------- 52 | 53 | 54 | ' ====================================================================== 55 | PROGRAM START 56 | ' ====================================================================== 57 | 58 | START: 59 | 60 | TX_BAUD = Terminal_Baud 61 | PAUSE 5000 62 | SEROUT TX_PIN, T115200, 16 63 | 64 | Main: 65 | 66 | Temp = %10000000000000000000111100001111 67 | TX_BIN Temp, 32 68 | TX_BYTE 13 69 | TX_BYTE 13 70 | 71 | Value = Invert_Bit Temp, 0 72 | TX_BIN Value, 32 73 | TX_BYTE 13 74 | TX_BYTE 13 75 | 76 | FOR Counter = 0 to 31 77 | Temp = Invert_Bit Temp, Counter 78 | NEXT 79 | TX_BIN Temp, 32 80 | TX_BYTE 13 81 | TX_BYTE 13 82 | 83 | 84 | 85 | END 86 | 87 | ' ---------------------------------------------------------------------- 88 | ' COG 0: SUB & FUNC Code 89 | ' ---------------------------------------------------------------------- 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Utilities/Sample Code/Transpose Bits Test.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' GLOBAL: Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ---------------------------------------------------------------------- 8 | ' GLOBAL: I/O Pins 9 | ' ---------------------------------------------------------------------- 10 | TX_PIN PIN 30 INPUT 11 | RX_PIN PIN 31 INPUT 12 | 13 | ' ---------------------------------------------------------------------- 14 | ' GLOBAL: Constants 15 | ' ---------------------------------------------------------------------- 16 | ' -- !!! You HAVE TO use Variables for the BAUD Rate/s 17 | Terminal_Baud CON 115200 18 | 19 | ' -- "TX_RX_Format_Lib_.pbas" Constants --------------- 20 | HOME CON 1 21 | CR CON 13 22 | CLS CON 16 23 | 24 | ' ---------------------------------------------------------------------- 25 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 26 | ' ---------------------------------------------------------------------- 27 | 28 | 29 | ' ---------------------------------------------------------------------- 30 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 31 | ' ---------------------------------------------------------------------- 32 | 33 | 34 | ' ---------------------------------------------------------------------- 35 | ' COG 0: Variables (Long only) 36 | ' ---------------------------------------------------------------------- 37 | TX_BAUD VAR LONG 38 | RX_BAUD VAR LONG 39 | 40 | Temp VAR LONG 41 | 42 | ' ---------------------------------------------------------------------- 43 | ' COG 0: SUB & FUNC Definitions 44 | ' ---------------------------------------------------------------------- 45 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB.pbas" 46 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 47 | LOAD "D:\Propeller\Propeller Programs\Libraries\UTILS_LIB.pbas" 48 | 49 | Swap_Bits2 FUNC 3 50 | 51 | ' ---------------------------------------------------------------------- 52 | ' TASK Definitions 53 | ' ---------------------------------------------------------------------- 54 | 55 | 56 | ' ====================================================================== 57 | PROGRAM START 58 | ' ====================================================================== 59 | 60 | START: 61 | 62 | TX_BAUD = Terminal_Baud 63 | RX_BAUD = Terminal_Baud 64 | 65 | DELAY_MS 5000 66 | TX_BYTE CLS 67 | 68 | Temp = %10000010_11000110_10101010 69 | 70 | TX_BIN Temp, 32 71 | TX_BYTE CR 72 | 73 | Temp = Transpose_Bits Temp,0, 8 74 | 75 | TX_BIN Temp, 32 76 | 77 | 78 | END 79 | 80 | 81 | ' ---------------------------------------------------------------------- 82 | ' COG 0: SUB & FUNC Code 83 | ' ---------------------------------------------------------------------- 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Utilities/Sample Code/PiezoX_Test.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' GLOBAL: Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ---------------------------------------------------------------------- 8 | ' GLOBAL: I/O Pins 9 | ' ---------------------------------------------------------------------- 10 | TX_PIN PIN 30 INPUT 11 | RX_PIN PIN 31 INPUT 12 | 13 | Speaker1 PIN 4 ' Piezo Buzzer Pin 1 14 | Speaker2 PIN 5 ' Piezo Buzzer Pin 2 15 | 16 | ' ---------------------------------------------------------------------- 17 | ' GLOBAL: Constants 18 | ' ---------------------------------------------------------------------- 19 | ' -- !!! You HAVE TO use Variables for the BAUD Rate/s 20 | Terminal_Baud CON 115200 21 | 22 | ' -- "TX_RX_Format_Lib_.pbas" Constants --------------- 23 | HOME CON 1 24 | CR CON 13 25 | CLS CON 16 26 | 27 | ' ---------------------------------------------------------------------- 28 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 29 | ' ---------------------------------------------------------------------- 30 | 31 | 32 | ' ---------------------------------------------------------------------- 33 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 34 | ' ---------------------------------------------------------------------- 35 | 36 | 37 | ' ---------------------------------------------------------------------- 38 | ' COG 0: Variables (Long only) 39 | ' ---------------------------------------------------------------------- 40 | TX_BAUD VAR LONG 41 | RX_BAUD VAR LONG 42 | 43 | Counter VAR LONG 44 | 45 | ' ---------------------------------------------------------------------- 46 | ' COG 0: SUB & FUNC Definitions 47 | ' ---------------------------------------------------------------------- 48 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB.pbas" 49 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 50 | LOAD "D:\Propeller\Propeller Programs\Libraries\UTILS_LIB.pbas" 51 | 52 | 53 | ' ---------------------------------------------------------------------- 54 | ' TASK Definitions 55 | ' ---------------------------------------------------------------------- 56 | 57 | 58 | ' ====================================================================== 59 | PROGRAM START 60 | ' ====================================================================== 61 | 62 | START: 63 | 64 | ' For an RS Piezo Speaker the working range = 100 to 170 with 133 and 137 being the loudest 65 | 66 | PiezoX Speaker1, Speaker2, 500, 140 67 | DELAY_MS 200 68 | 69 | PiezoX Speaker1, Speaker2, 800, 135 70 | DELAY_MS 200 71 | 72 | PiezoX Speaker1, Speaker2, 1200, 160 73 | DELAY_MS 1000 74 | 75 | 76 | END 77 | 78 | ' ---------------------------------------------------------------------- 79 | ' COG 0: SUB & FUNC Code 80 | ' ---------------------------------------------------------------------- 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/LCD Connected via IO Expander/Libraries/LCD_EXPANDER_LIB_SUBS.pbas: -------------------------------------------------------------------------------- 1 | 2 | 3 | ' LOADing seperate SUBS and CODE files works in the Main Program as well as in Tasks 4 | 5 | 6 | ' ************************************************************************************************************** 7 | ' NOTE: The Main Program MUST contain these two Variables because thy are used by this Library 8 | 9 | ' LCD_Data VAR LONG ' Data sent by Main Program to LCD. 10 | ' LCD_BUS_Data VAR LONG ' Used Internally by LCD_EXPANDER_LIB.pbas 11 | 12 | ' ************************************************************************************************************** 13 | 14 | 15 | 16 | ' !!!! NOTE: SUB WRITE_LCD is different for each of the different Expanders, so this LIB does not have a SUB for WRITE_LCD. 17 | ' SUB WRITE_LCD MUST be coded in the Main Program depending on which Expander you sre using. 18 | ' Examples: 19 | 20 | ' SUB Definition is the Same for all Expanders 21 | ' WRITE_LCD SUB 1 22 | 23 | ' ************************************************************************************************************** 24 | ' I2C (PCF8574, MCP23008 & LCD2204 LCD Backpack 25 | ' SUB WRITE_LCD 26 | ' I2C_Out __param1, 1 27 | ' ENDSUB 28 | ' ************************************************************************************************************** 29 | 30 | 31 | ' ************************************************************************************************************** 32 | ' 74HC595: 33 | ' SUB WRITE_LCD 34 | ' SHIFTOUT SR_Data, SR_Clock, MSBFIRST, __param1\8 ' send the bits 35 | ' PULSOUT SR_Latch, 1 ' transfer to outputs 36 | ' ENDSUB 37 | ' ************************************************************************************************************** 38 | 39 | 40 | ' ************************************************************************************************************** 41 | ' MCP23S08: 42 | ' SUB WRITE_LCD 43 | ' LOW CS 44 | ' SHIFTOUT SI, SCK, MSBFIRST, Expander\8 45 | ' SHIFTOUT SI, SCK, MSBFIRST, Register_Address\8 46 | ' SHIFTOUT SI, SCK, MSBFIRST, __param1\8 47 | ' HIGH CS 48 | ' ENDSUB 49 | ' ************************************************************************************************************** 50 | 51 | 52 | 53 | ' LCD PIN Mapping to IO Expander LCD_BUS_Data Bits 54 | ' LCD_BL CON 0 55 | ' LCD_RS CON 1 56 | ' LCD_RW CON 2 57 | ' LCD_E CON 3 58 | ' LCD_D4 CON 4 59 | ' LCD_D5 CON 5 60 | ' LCD_D6 CON 6 61 | ' LCD_D7 CON 7 62 | 63 | 64 | LCD_INIT SUB 0 ' Initialise the LCD in 4-BIT Mode 65 | LCD_CMD SUB 1 ' Send Command Code to LCD 66 | LCD_BYTE SUB 1 ' Write a Byte to the LCD 67 | LCD_STR SUB 1, 2 ' Write a String to the LCD 68 | LCD_DEC SUB 2 ' Write a Number to the LCD - No Leading Spaces, No Leading Zeroes 69 | LCD_DECLZ SUB 2 ' Write a Number to the LCD with Leading Zeroes 70 | LCD_DECLS SUB 2 ' Write a Number to the LCD with Leading Spaces 71 | LCD_Get_Digit FUNC 2 ' Used by LCD_DEC, LCD_DECLS and LCD_DECLZ 72 | LCD_ON SUB 0 ' Turn LCD and Backlight ON 73 | LCD_OFF SUB 0 ' Turn LCD and Backlight OFF 74 | LCD_CLEAR SUB 0 ' Clear LCD Screen -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Utilities/Sample Code/Freq_Out_Test.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' GLOBAL: Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ---------------------------------------------------------------------- 8 | ' GLOBAL: I/O Pins 9 | ' ---------------------------------------------------------------------- 10 | TX_PIN PIN 30 INPUT 11 | RX_PIN PIN 31 INPUT 12 | 13 | Speaker PIN 4 ' Piezo Buzzer 14 | 15 | ' ---------------------------------------------------------------------- 16 | ' GLOBAL: Constants 17 | ' ---------------------------------------------------------------------- 18 | ' -- !!! You HAVE TO use Variables for the BAUD Rate/s 19 | Terminal_Baud CON 115200 20 | 21 | ' -- "TX_RX_Format_Lib_.pbas" Constants --------------- 22 | HOME CON 1 23 | CR CON 13 24 | CLS CON 16 25 | 26 | ' ---------------------------------------------------------------------- 27 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 28 | ' ---------------------------------------------------------------------- 29 | 30 | 31 | ' ---------------------------------------------------------------------- 32 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 33 | ' ---------------------------------------------------------------------- 34 | 35 | 36 | ' ---------------------------------------------------------------------- 37 | ' COG 0: Variables (Long only) 38 | ' ---------------------------------------------------------------------- 39 | TX_BAUD VAR LONG 40 | RX_BAUD VAR LONG 41 | 42 | ' Target VAR LONG 43 | 44 | Counter VAR LONG 45 | 46 | ' ---------------------------------------------------------------------- 47 | ' COG 0: SUB & FUNC Definitions 48 | ' ---------------------------------------------------------------------- 49 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB.pbas" 50 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 51 | LOAD "D:\Propeller\Propeller Programs\Libraries\UTILS_LIB.pbas" 52 | 53 | ' ---------------------------------------------------------------------- 54 | ' TASK Definitions 55 | ' ---------------------------------------------------------------------- 56 | 57 | 58 | ' ====================================================================== 59 | PROGRAM START 60 | ' ====================================================================== 61 | 62 | START: 63 | 64 | TX_BAUD = Terminal_Baud 65 | RX_BAUD = Terminal_Baud 66 | 67 | Freq_Out Speaker, 50, 3500 68 | DELAY_MS 1000 69 | Freq_Out Speaker, 75, 3500 70 | DELAY_MS 1000 71 | Freq_Out Speaker, 100, 3500 72 | DELAY_MS 1000 73 | Freq_Out Speaker, 200, 3500 74 | DELAY_MS 1000 75 | Freq_Out Speaker, 300, 3500 76 | DELAY_MS 1000 77 | Freq_Out Speaker, 400, 3500 78 | DELAY_MS 1000 79 | Freq_Out Speaker, 500, 3500 80 | 81 | 82 | END 83 | 84 | ' ---------------------------------------------------------------------- 85 | ' COG 0: SUB & FUNC Code 86 | ' ---------------------------------------------------------------------- 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Utilities/Sample Code/Put_Get_Nib_Test.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ---------------------------------------------------------------------- 8 | ' GLOBAL: I/O Pins 9 | ' ---------------------------------------------------------------------- 10 | TX_PIN PIN 30 INPUT 11 | 12 | ' ---------------------------------------------------------------------- 13 | ' GLOBAL: Constants 14 | ' ---------------------------------------------------------------------- 15 | Terminal_Baud CON 115200 16 | 17 | ' ---------------------------------------------------------------------- 18 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 19 | ' ---------------------------------------------------------------------- 20 | 21 | 22 | ' ---------------------------------------------------------------------- 23 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 24 | ' ---------------------------------------------------------------------- 25 | 26 | 27 | ' ---------------------------------------------------------------------- 28 | ' COG 0: Variables (Long only) 29 | ' ---------------------------------------------------------------------- 30 | TX_BAUD VAR LONG 31 | 32 | Temp VAR Long 33 | 34 | Value VAR Long 35 | 36 | 37 | 38 | 39 | ' ---------------------------------------------------------------------- 40 | ' COG 0: SUB & FUNC Definitions 41 | ' ---------------------------------------------------------------------- 42 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 43 | LOAD "D:\Propeller\Propeller Programs\Libraries\UTILS_LIB.pbas" 44 | 45 | 46 | ' ---------------------------------------------------------------------- 47 | ' TASK Definitions 48 | ' ---------------------------------------------------------------------- 49 | 50 | 51 | ' ====================================================================== 52 | PROGRAM START 53 | ' ====================================================================== 54 | 55 | START: 56 | 57 | TX_BAUD = Terminal_Baud 58 | PAUSE 5000 59 | TX_BYTE 16 60 | 61 | Main: 62 | 63 | Temp = 0 64 | 65 | Temp = Put_Nib %1001, Temp, 0 66 | TX_BIN Temp, 32 67 | TX_BYTE 13 68 | TX_BYTE 13 69 | 70 | Temp = Put_Nib %1111, Temp, 7 71 | TX_BIN Temp, 32 72 | TX_BYTE 13 73 | TX_BYTE 13 74 | 75 | Value = Get_Nib Temp, 0 76 | TX_BIN Value, 32 77 | TX_BYTE 13 78 | TX_BYTE 13 79 | TX_BYTE 13 80 | 81 | 82 | Temp = Put_Nib %1101, Temp, 2 83 | TX_BIN Temp, 32 84 | TX_BYTE 13 85 | TX_BYTE 13 86 | 87 | Temp = Put_Nib %0000, Temp, 7 88 | TX_BIN Temp, 32 89 | TX_BYTE 13 90 | TX_BYTE 13 91 | 92 | Value = Get_Nib Temp, 7 93 | TX_BIN Value, 32 94 | TX_BYTE 13 95 | TX_BYTE 13 96 | 97 | 98 | 99 | END 100 | 101 | ' ---------------------------------------------------------------------- 102 | ' COG 0: SUB & FUNC Code 103 | ' ---------------------------------------------------------------------- 104 | 105 | ' -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Utilities/Sample Code/Put_Get_Byte_Test.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ---------------------------------------------------------------------- 8 | ' GLOBAL: I/O Pins 9 | ' ---------------------------------------------------------------------- 10 | TX_PIN PIN 30 INPUT 11 | 12 | ' ---------------------------------------------------------------------- 13 | ' GLOBAL: Constants 14 | ' ---------------------------------------------------------------------- 15 | Terminal_Baud CON 115200 16 | 17 | ' ---------------------------------------------------------------------- 18 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 19 | ' ---------------------------------------------------------------------- 20 | 21 | 22 | ' ---------------------------------------------------------------------- 23 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 24 | ' ---------------------------------------------------------------------- 25 | 26 | 27 | ' ---------------------------------------------------------------------- 28 | ' COG 0: Variables (Long only) 29 | ' ---------------------------------------------------------------------- 30 | TX_BAUD VAR LONG 31 | 32 | Temp VAR Long 33 | 34 | Value VAR Long 35 | 36 | 37 | 38 | 39 | ' ---------------------------------------------------------------------- 40 | ' COG 0: SUB & FUNC Definitions 41 | ' ---------------------------------------------------------------------- 42 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 43 | LOAD "D:\Propeller\Propeller Programs\Libraries\UTILS_LIB.pbas" 44 | 45 | 46 | 47 | ' ---------------------------------------------------------------------- 48 | ' TASK Definitions 49 | ' ---------------------------------------------------------------------- 50 | 51 | 52 | ' ====================================================================== 53 | PROGRAM START 54 | ' ====================================================================== 55 | 56 | START: 57 | 58 | TX_BAUD = Terminal_Baud 59 | PAUSE 5000 60 | TX_BYTE 16 61 | 62 | Main: 63 | 64 | Temp = 0 65 | 66 | Temp = Put_Byte %10011001, Temp, 0 67 | TX_BIN Temp, 32 68 | TX_BYTE 13 69 | TX_BYTE 13 70 | 71 | Temp = Put_Byte %11111111, Temp, 3 72 | TX_BIN Temp, 32 73 | TX_BYTE 13 74 | TX_BYTE 13 75 | 76 | Value = Get_Byte Temp, 3 77 | TX_BIN Value, 32 78 | TX_BYTE 13 79 | TX_BYTE 13 80 | TX_BYTE 13 81 | 82 | 83 | Temp = Put_Byte %11000011, Temp, 2 84 | TX_BIN Temp, 32 85 | TX_BYTE 13 86 | TX_BYTE 13 87 | 88 | Temp = Put_Byte %00000000, Temp, 3 89 | TX_BIN Temp, 32 90 | TX_BYTE 13 91 | TX_BYTE 13 92 | 93 | Value = Get_Byte Temp, 2 94 | TX_BIN Value, 32 95 | TX_BYTE 13 96 | TX_BYTE 13 97 | 98 | 99 | 100 | END 101 | 102 | ' ---------------------------------------------------------------------- 103 | ' COG 0: SUB & FUNC Code 104 | ' ---------------------------------------------------------------------- 105 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Utilities/Sample Code/Put_Get_Bit_Test.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ---------------------------------------------------------------------- 8 | ' GLOBAL: I/O Pins 9 | ' ---------------------------------------------------------------------- 10 | TX_PIN PIN 30 INPUT 11 | 12 | ' ---------------------------------------------------------------------- 13 | ' GLOBAL: Constants 14 | ' ---------------------------------------------------------------------- 15 | Terminal_Baud CON 115200 16 | 17 | ' ---------------------------------------------------------------------- 18 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 19 | ' ---------------------------------------------------------------------- 20 | 21 | 22 | ' ---------------------------------------------------------------------- 23 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 24 | ' ---------------------------------------------------------------------- 25 | 26 | 27 | ' ---------------------------------------------------------------------- 28 | ' COG 0: Variables (Long only) 29 | ' ---------------------------------------------------------------------- 30 | TX_BAUD VAR LONG 31 | 32 | Temp VAR Long 33 | 34 | Value VAR Long 35 | 36 | 37 | 38 | 39 | ' ---------------------------------------------------------------------- 40 | ' COG 0: SUB & FUNC Definitions 41 | ' ---------------------------------------------------------------------- 42 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 43 | LOAD "D:\Propeller\Propeller Programs\Libraries\UTILS_LIB.pbas" 44 | 45 | 46 | ' ---------------------------------------------------------------------- 47 | ' TASK Definitions 48 | ' ---------------------------------------------------------------------- 49 | 50 | 51 | ' ====================================================================== 52 | PROGRAM START 53 | ' ====================================================================== 54 | 55 | START: 56 | 57 | TX_BAUD = Terminal_Baud 58 | PAUSE 5000 59 | TX_BYTE 16 60 | 61 | Main: 62 | 63 | Temp = 0 64 | 65 | Temp = Put_Bit 1, Temp, 0 66 | TX_BIN Temp, 32 67 | TX_BYTE 13 68 | TX_BYTE 13 69 | 70 | Temp = Put_Bit 1, Temp, 3 71 | TX_BIN Temp, 32 72 | TX_BYTE 13 73 | TX_BYTE 13 74 | 75 | Temp = Put_Bit 1, Temp, 7 76 | TX_BIN Temp, 32 77 | TX_BYTE 13 78 | TX_BYTE 13 79 | 80 | Temp = Put_Bit 0, Temp, 3 81 | TX_BIN Temp, 32 82 | TX_BYTE 13 83 | TX_BYTE 13 84 | 85 | Temp = Put_Bit 0, Temp, 7 86 | TX_BIN Temp, 32 87 | TX_BYTE 13 88 | TX_BYTE 13 89 | 90 | Temp = Put_Bit 1, Temp, 31 91 | TX_BIN Temp, 32 92 | TX_BYTE 13 93 | TX_BYTE 13 94 | 95 | Value = Get_Bit Temp, 31 96 | TX_BIN Value, 32 97 | TX_BYTE 13 98 | TX_BYTE 13 99 | TX_BYTE 13 100 | 101 | 102 | 103 | END 104 | 105 | ' ---------------------------------------------------------------------- 106 | ' COG 0: SUB & FUNC Code 107 | ' ---------------------------------------------------------------------- -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Utilities/Sample Code/Freq_OutX_Test.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' GLOBAL: Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ---------------------------------------------------------------------- 8 | ' GLOBAL: I/O Pins 9 | ' ---------------------------------------------------------------------- 10 | TX_PIN PIN 30 INPUT 11 | RX_PIN PIN 31 INPUT 12 | 13 | Speaker1 PIN 4 ' Piezo Buzzer Pin 1 14 | Speaker2 PIN 5 ' Piezo Buzzer Pin 2 15 | 16 | 17 | ' ---------------------------------------------------------------------- 18 | ' GLOBAL: Constants 19 | ' ---------------------------------------------------------------------- 20 | ' -- !!! You HAVE TO use Variables for the BAUD Rate/s 21 | Terminal_Baud CON 115200 22 | 23 | ' -- "TX_RX_Format_Lib_.pbas" Constants --------------- 24 | HOME CON 1 25 | CR CON 13 26 | CLS CON 16 27 | 28 | ' ---------------------------------------------------------------------- 29 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 30 | ' ---------------------------------------------------------------------- 31 | 32 | 33 | ' ---------------------------------------------------------------------- 34 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 35 | ' ---------------------------------------------------------------------- 36 | 37 | 38 | ' ---------------------------------------------------------------------- 39 | ' COG 0: Variables (Long only) 40 | ' ---------------------------------------------------------------------- 41 | TX_BAUD VAR LONG 42 | RX_BAUD VAR LONG 43 | 44 | ' Target VAR LONG 45 | 46 | Counter VAR LONG 47 | 48 | ' ---------------------------------------------------------------------- 49 | ' COG 0: SUB & FUNC Definitions 50 | ' ---------------------------------------------------------------------- 51 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB.pbas" 52 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 53 | LOAD "D:\Propeller\Propeller Programs\Libraries\UTILS_LIB.pbas" 54 | 55 | ' ---------------------------------------------------------------------- 56 | ' TASK Definitions 57 | ' ---------------------------------------------------------------------- 58 | 59 | 60 | ' ====================================================================== 61 | PROGRAM START 62 | ' ====================================================================== 63 | 64 | START: 65 | 66 | 67 | Freq_OutX Speaker1, Speaker2, 50, 3500 68 | DELAY_MS 1000 69 | Freq_OutX Speaker1, Speaker2, 75, 3500 70 | DELAY_MS 1000 71 | Freq_OutX Speaker1, Speaker2, 100, 3500 72 | DELAY_MS 1000 73 | Freq_OutX Speaker1, Speaker2, 200, 3500 74 | DELAY_MS 1000 75 | Freq_OutX Speaker1, Speaker2, 300, 3500 76 | DELAY_MS 1000 77 | Freq_OutX Speaker1, Speaker2, 400, 3500 78 | DELAY_MS 1000 79 | Freq_OutX Speaker1, Speaker2, 500, 3500 80 | 81 | 82 | 83 | 84 | 85 | END 86 | 87 | ' ---------------------------------------------------------------------- 88 | ' COG 0: SUB & FUNC Code 89 | ' ---------------------------------------------------------------------- 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Program Templates/Blank_Template_Without_Task_Variable_TX_RX_Pins.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' GLOBAL: Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ---------------------------------------------------------------------- 8 | ' GLOBAL: I/O Pins 9 | ' ---------------------------------------------------------------------- 10 | ' TX_PIN PIN 30 INPUT 11 | ' RX_PIN PIN 31 INPUT 12 | 13 | TerminalTX PIN 30 ' If you going to use a PIN for an Absolute Pin Value assigment, the Pin Symbol CAN NOT have an "_" in it, 14 | ' e.g. Terminal_TX DOES NOT work !!!! 15 | TerminalRX PIN 31 16 | 17 | ' ---------------------------------------------------------------------- 18 | ' GLOBAL: Constants 19 | ' ---------------------------------------------------------------------- 20 | ' -- !!! You HAVE TO use Variables for the BAUD Rate/s 21 | Terminal_Baud CON 115200 22 | 23 | 24 | ' -- "TX_RX_Format_Lib_.pbas" Constants --------------- 25 | HOME CON 1 26 | CR CON 13 27 | CLS CON 16 28 | 29 | ' ---------------------------------------------------------------------- 30 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 31 | ' ---------------------------------------------------------------------- 32 | 33 | 34 | ' ---------------------------------------------------------------------- 35 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 36 | ' ---------------------------------------------------------------------- 37 | 38 | 39 | ' ---------------------------------------------------------------------- 40 | ' COG 0: Variables (Long only) 41 | ' ---------------------------------------------------------------------- 42 | TX_BAUD VAR LONG 43 | RX_BAUD VAR LONG 44 | 45 | TX_PIN VAR LONG 46 | RX_PIN VAR LONG 47 | 48 | ' ---------------------------------------------------------------------- 49 | ' COG 0: SUB & FUNC Definitions 50 | ' ---------------------------------------------------------------------- 51 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB.pbas" 52 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 53 | LOAD "D:\Propeller\Propeller Programs\Libraries\I2C_LIB.pbas" 54 | LOAD "D:\Propeller\Propeller Programs\Libraries\UTILS_LIB.pbas" 55 | 56 | 57 | ' ---------------------------------------------------------------------- 58 | ' TASK Definitions 59 | ' ---------------------------------------------------------------------- 60 | 61 | Task1 TASK 62 | 63 | 64 | ' ====================================================================== 65 | PROGRAM START 66 | ' ====================================================================== 67 | 68 | START: 69 | 70 | TX_BAUD = Terminal_Baud 71 | RX_BAUD = Terminal_Baud 72 | 73 | TX_PIN = #TerminalTX ' If you use an Absolute Pin Value assigment like this, the Pin Symbol CAN NOT have an "_" in it, e.g. Terminal_TX DOES NOT work !!!! 74 | RX_PIN = #TerminalRX 75 | 76 | DELAY_MS 5000 77 | TX_BYTE CLS 78 | 79 | 80 | 81 | END 82 | 83 | 84 | ' ---------------------------------------------------------------------- 85 | ' COG 0: SUB & FUNC Code 86 | ' ---------------------------------------------------------------------- 87 | 88 | 89 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/TX-RX/Sample Code/Blank_Template_Without_Task_Variable_TX_RX_Pins.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' GLOBAL: Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ---------------------------------------------------------------------- 8 | ' GLOBAL: I/O Pins 9 | ' ---------------------------------------------------------------------- 10 | ' TX_PIN PIN 30 INPUT 11 | ' RX_PIN PIN 31 INPUT 12 | 13 | TerminalTX PIN 30 ' If you going to use a PIN for an Absolute Pin Value assigment, the Pin Symbol CAN NOT have an "_" in it, 14 | ' e.g. Terminal_TX DOES NOT work !!!! 15 | TerminalRX PIN 31 16 | 17 | ' ---------------------------------------------------------------------- 18 | ' GLOBAL: Constants 19 | ' ---------------------------------------------------------------------- 20 | ' -- !!! You HAVE TO use Variables for the BAUD Rate/s 21 | Terminal_Baud CON 115200 22 | 23 | 24 | ' -- "TX_RX_Format_Lib_.pbas" Constants --------------- 25 | HOME CON 1 26 | CR CON 13 27 | CLS CON 16 28 | 29 | ' ---------------------------------------------------------------------- 30 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 31 | ' ---------------------------------------------------------------------- 32 | 33 | 34 | ' ---------------------------------------------------------------------- 35 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 36 | ' ---------------------------------------------------------------------- 37 | 38 | 39 | ' ---------------------------------------------------------------------- 40 | ' COG 0: Variables (Long only) 41 | ' ---------------------------------------------------------------------- 42 | TX_BAUD VAR LONG 43 | RX_BAUD VAR LONG 44 | 45 | TX_PIN VAR LONG 46 | RX_PIN VAR LONG 47 | 48 | ' ---------------------------------------------------------------------- 49 | ' COG 0: SUB & FUNC Definitions 50 | ' ---------------------------------------------------------------------- 51 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB.pbas" 52 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 53 | LOAD "D:\Propeller\Propeller Programs\Libraries\I2C_LIB.pbas" 54 | LOAD "D:\Propeller\Propeller Programs\Libraries\UTILS_LIB.pbas" 55 | 56 | 57 | ' ---------------------------------------------------------------------- 58 | ' TASK Definitions 59 | ' ---------------------------------------------------------------------- 60 | 61 | Task1 TASK 62 | 63 | 64 | ' ====================================================================== 65 | PROGRAM START 66 | ' ====================================================================== 67 | 68 | START: 69 | 70 | TX_BAUD = Terminal_Baud 71 | RX_BAUD = Terminal_Baud 72 | 73 | TX_PIN = #TerminalTX ' If you use an Absolute Pin Value assigment like this, the Pin Symbol CAN NOT have an "_" in it, e.g. Terminal_TX DOES NOT work !!!! 74 | RX_PIN = #TerminalRX 75 | 76 | DELAY_MS 5000 77 | TX_BYTE CLS 78 | 79 | 80 | 81 | END 82 | 83 | 84 | ' ---------------------------------------------------------------------- 85 | ' COG 0: SUB & FUNC Code 86 | ' ---------------------------------------------------------------------- 87 | 88 | 89 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Utilities/Sample Code/Piezo_Test.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' GLOBAL: Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ---------------------------------------------------------------------- 8 | ' GLOBAL: I/O Pins 9 | ' ---------------------------------------------------------------------- 10 | TX_PIN PIN 30 INPUT 11 | RX_PIN PIN 31 INPUT 12 | 13 | Speaker PIN 0 ' Piezo Buzzer 14 | 15 | 16 | ' ---------------------------------------------------------------------- 17 | ' GLOBAL: Constants 18 | ' ---------------------------------------------------------------------- 19 | ' -- !!! You HAVE TO use Variables for the BAUD Rate/s 20 | Terminal_Baud CON 115200 21 | 22 | ' -- "TX_RX_Format_Lib_.pbas" Constants --------------- 23 | HOME CON 1 24 | CR CON 13 25 | CLS CON 16 26 | 27 | ' ---------------------------------------------------------------------- 28 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 29 | ' ---------------------------------------------------------------------- 30 | 31 | 32 | ' ---------------------------------------------------------------------- 33 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 34 | ' ---------------------------------------------------------------------- 35 | 36 | 37 | ' ---------------------------------------------------------------------- 38 | ' COG 0: Variables (Long only) 39 | ' ---------------------------------------------------------------------- 40 | TX_BAUD VAR LONG 41 | RX_BAUD VAR LONG 42 | 43 | Counter VAR LONG 44 | 45 | ' ---------------------------------------------------------------------- 46 | ' COG 0: SUB & FUNC Definitions 47 | ' ---------------------------------------------------------------------- 48 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB.pbas" 49 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 50 | ' LOAD "D:\Propeller\Propeller Programs\Libraries\I2C_LIB.pbas" 51 | LOAD "D:\Propeller\Propeller Programs\Libraries\UTILS_LIB.pbas" 52 | 53 | ' ---------------------------------------------------------------------- 54 | ' TASK Definitions 55 | ' ---------------------------------------------------------------------- 56 | 57 | 58 | ' ====================================================================== 59 | PROGRAM START 60 | ' ====================================================================== 61 | 62 | START: 63 | 64 | TX_BAUD = Terminal_Baud 65 | RX_BAUD = Terminal_Baud 66 | 67 | ' DELAY_MS 5000 68 | ' TX_BYTE CLS 69 | 70 | ' For an RS Piezo Speaker the working range = 100 to 170 with 133 and 137 being the loudest 71 | 72 | DO 73 | 74 | FOR Counter = 130 to 140 75 | 76 | TX_DEC Counter 77 | TX_BYTE CR 78 | 79 | Piezo Speaker, 2000, Counter 80 | 81 | DELAY_MS 500 82 | 83 | NEXT 84 | 85 | 86 | LOOP 87 | 88 | 89 | END 90 | 91 | ' ---------------------------------------------------------------------- 92 | ' COG 0: SUB & FUNC Code 93 | ' ---------------------------------------------------------------------- 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Utilities/Sample Code/Copy_Byte_Test.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ---------------------------------------------------------------------- 8 | ' GLOBAL: I/O Pins 9 | ' ---------------------------------------------------------------------- 10 | TX_PIN PIN 30 INPUT 11 | 12 | ' ---------------------------------------------------------------------- 13 | ' GLOBAL: Constants 14 | ' ---------------------------------------------------------------------- 15 | Terminal_Baud CON 115200 16 | 17 | ' ---------------------------------------------------------------------- 18 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 19 | ' ---------------------------------------------------------------------- 20 | 21 | 22 | ' ---------------------------------------------------------------------- 23 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 24 | ' ---------------------------------------------------------------------- 25 | 26 | 27 | ' ---------------------------------------------------------------------- 28 | ' COG 0: Variables (Long only) 29 | ' ---------------------------------------------------------------------- 30 | TX_BAUD VAR LONG 31 | 32 | Temp VAR Long 33 | 34 | Value VAR Long 35 | 36 | 37 | 38 | 39 | ' ---------------------------------------------------------------------- 40 | ' COG 0: SUB & FUNC Definitions 41 | ' ---------------------------------------------------------------------- 42 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 43 | LOAD "D:\Propeller\Propeller Programs\Libraries\UTILS_LIB.pbas" 44 | 45 | 46 | ' ---------------------------------------------------------------------- 47 | ' TASK Definitions 48 | ' ---------------------------------------------------------------------- 49 | 50 | 51 | ' ====================================================================== 52 | PROGRAM START 53 | ' ====================================================================== 54 | 55 | START: 56 | 57 | TX_BAUD = Terminal_Baud 58 | PAUSE 5000 59 | SEROUT TX_PIN, T115200, 16 60 | 61 | Main: 62 | 63 | Value = %10011001_11111111_10000001 64 | 65 | Temp = Copy_Byte Value, 0, Temp, 0 66 | TX_BIN Temp, 32 67 | TX_BYTE 13 68 | TX_BYTE 13 69 | 70 | Temp = Copy_Byte Value, 1, Temp, 0 71 | TX_BIN Temp, 32 72 | TX_BYTE 13 73 | TX_BYTE 13 74 | 75 | Temp = Copy_Byte Value, 2, Temp, 3 76 | TX_BIN Temp, 32 77 | TX_BYTE 13 78 | TX_BYTE 13 79 | 80 | Temp = Copy_Byte Value, 2, Temp, 3 81 | TX_BIN Temp, 32 82 | TX_BYTE 13 83 | TX_BYTE 13 84 | 85 | Temp = Copy_Byte %11111111, 0, Temp, 1 ' Nib is a literal 86 | TX_BIN Temp, 32 87 | TX_BYTE 13 88 | TX_BYTE 13 89 | 90 | Temp = Copy_Byte %00000000, 0, Temp, 1 ' NIb is a literal 91 | TX_BIN Temp, 32 92 | TX_BYTE 13 93 | TX_BYTE 13 94 | 95 | Temp = Copy_Byte %00000000, 0, Temp, 1 ' NIb is a literal 96 | TX_BIN Temp, 32 97 | TX_BYTE 13 98 | TX_BYTE 13 99 | 100 | 101 | 102 | 103 | END 104 | 105 | ' ---------------------------------------------------------------------- 106 | ' COG 0: SUB & FUNC Code 107 | ' ---------------------------------------------------------------------- -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/TX-RX/Libraries/TX_RX_LIB_SUBS.pbas: -------------------------------------------------------------------------------- 1 | ' ====================================================================== 2 | ' Serial IO Library for PropBASIC 3 | ' -- by Jon McPhalen 4 | ' -- 22 MAY 2010 5 | ' -- requires PropBASIC 0.98a or later 6 | ' ====================================================================== 7 | 8 | ' LOADing seperate SUBS and CODE files works in the Main Program as well as in Tasks 9 | 10 | ' This is based on Jonny Mac's "pst_serial_lib.pbas" 11 | ' CHANGES: 12 | ' * The PST Control Codes are commented out so that you can put them in the Main Program 13 | ' * I have also Added TX_DECX which allows you to Specifiy how many Digits to send 14 | 15 | ' * MAJOR CHANGE: 16 | ' The Library has been Generalized to allow changing of Baud Rates and/or TX/RX Pins in Program code, e.g. writing to different Serial LCDs 17 | ' The following are HARDCODED in this Library and MUST be used in the Program Code: 18 | ' ---------------------------------------------------------------------- 19 | ' I/O Pins 20 | ' ---------------------------------------------------------------------- 21 | ' TX_PIN 22 | ' RX_PIN 23 | 24 | ' ---------------------------------------------------------------------- 25 | ' Variables 26 | ' ---------------------------------------------------------------------- 27 | ' TX_BAUD 28 | ' RX_BAUD 29 | 30 | 31 | 32 | 33 | ' PST control codes 34 | ' HOME CON 1 35 | ' GOTOXY CON 2 36 | ' CRSRLF CON 3 37 | ' CRSRRT CON 4 38 | ' CRSRUP CON 5 39 | ' CRSRDN CON 6 40 | ' BEEP CON 7 41 | ' BKSP CON 8 42 | ' TAB CON 9 43 | ' LF CON 10 44 | ' CLREOL CON 11 45 | ' CLRDN CON 12 46 | ' CR CON 13 47 | ' GOTOX CON 14 48 | ' GOTOY CON 15 49 | ' CLS CON 16 ' allow use in strings 50 | 51 | 52 | ' ---------------------------------------------------------------------- 53 | 54 | RX_STR SUB 1, 2 ' rx a string 55 | RX_BIN FUNC 0, 1 ' rx binary value 56 | RX_HEX FUNC 0, 1 ' rx hex value 57 | RX_DEC FUNC 0, 1 ' rx decimal value 58 | RX_BYTE FUNC 0 ' shell for SERIN 59 | 60 | TX_STR SUB 1, 2 ' tx a string. You can optionally specify a termination character in __param2, e.g. "@". 61 | ' This is useful for when the DATA that you want to TX contains zeros. 62 | ' If you do not use __param2, then "0" must be used as the termination character. 63 | 64 | TX_BIN SUB 1, 2 ' tx value as binary 65 | TX_HEX SUB 1, 2 ' tx value as hex 66 | TX_DEC SUB 1 ' tx value as decimal. This is the Original - You CANNOT specify the number of digits to display 67 | TX_DECX SUB 1, 2 ' NEW: tx value as decimal. This is my own version - You CAN specify the number of digits to display 68 | TX_RPT SUB 2 ' tx byte x times 69 | TX_BYTE SUB 1 ' shell for SEROUT 70 | 71 | UCASE FUNC 1 ' alpha to uppercase 72 | MULT_10 FUNC 1 ' x10 -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Utilities/Sample Code/Get_Digit_Test.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' GLOBAL: Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ---------------------------------------------------------------------- 8 | ' GLOBAL: I/O Pins 9 | ' ---------------------------------------------------------------------- 10 | TX_PIN PIN 30 INPUT 11 | RX_PIN PIN 31 INPUT 12 | 13 | ' ---------------------------------------------------------------------- 14 | ' GLOBAL: Constants 15 | ' ---------------------------------------------------------------------- 16 | ' -- !!! You HAVE TO use Variables for the BAUD Rate/s 17 | Terminal_Baud CON 115200 18 | 19 | ' -- "TX_RX_Format_Lib_.pbas" Constants --------------- 20 | HOME CON 1 21 | CR CON 13 22 | CLS CON 16 23 | 24 | ' ---------------------------------------------------------------------- 25 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 26 | ' ---------------------------------------------------------------------- 27 | 28 | ' ---------------------------------------------------------------------- 29 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 30 | ' ---------------------------------------------------------------------- 31 | 32 | ' ---------------------------------------------------------------------- 33 | ' COG 0: Variables (Long only) 34 | ' ---------------------------------------------------------------------- 35 | TX_BAUD VAR LONG 36 | RX_BAUD VAR LONG 37 | 38 | Counter VAR LONG 39 | Temp VAR LONG 40 | Digit VAR LONG 41 | 42 | ' ---------------------------------------------------------------------- 43 | ' COG 0: SUB & FUNC Definitions 44 | ' ---------------------------------------------------------------------- 45 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB.pbas" 46 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 47 | LOAD "D:\Propeller\Propeller Programs\Libraries\UTILS_LIB.pbas" 48 | 49 | 50 | ' ---------------------------------------------------------------------- 51 | ' TASK Definitions 52 | ' ---------------------------------------------------------------------- 53 | 54 | 55 | ' ====================================================================== 56 | PROGRAM START 57 | ' ====================================================================== 58 | 59 | START: 60 | 61 | TX_BAUD = Terminal_Baud 62 | RX_BAUD = Terminal_Baud 63 | 64 | DELAY_MS 5000 65 | TX_BYTE CLS 66 | 67 | Temp = 987654321 ' 123456789 68 | 69 | TX_STR "Original Value : " 70 | TX_DEC Temp 71 | TX_BYTE 13 72 | TX_BYTE 13 73 | 74 | FOR Counter = 7 to 8 ' 0 to 7 75 | 76 | TX_STR "Digit : " 77 | TX_DEC Counter 78 | TX_BYTE 13 79 | 80 | Digit = Get_Digit Temp, Counter 81 | 82 | TX_STR "Decimal : " 83 | TX_DEC Digit 84 | TX_BYTE 13 85 | 86 | 87 | Digit = Digit + $30 ' Convert to ASCII 88 | 89 | TX_STR "ASCII : " 90 | TX_BYTE Digit 91 | TX_BYTE 13 92 | TX_BYTE 13 93 | 94 | NEXT 95 | 96 | 97 | END 98 | 99 | 100 | ' ---------------------------------------------------------------------- 101 | ' COG 0: SUB & FUNC Code 102 | ' ---------------------------------------------------------------------- 103 | 104 | 105 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Utilities/Sample Code/Copy_Bit_Test.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ---------------------------------------------------------------------- 8 | ' GLOBAL: I/O Pins 9 | ' ---------------------------------------------------------------------- 10 | TX_PIN PIN 30 INPUT 11 | 12 | ' ---------------------------------------------------------------------- 13 | ' GLOBAL: Constants 14 | ' ---------------------------------------------------------------------- 15 | Terminal_Baud CON 115200 16 | 17 | ' ---------------------------------------------------------------------- 18 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 19 | ' ---------------------------------------------------------------------- 20 | 21 | 22 | ' ---------------------------------------------------------------------- 23 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 24 | ' ---------------------------------------------------------------------- 25 | 26 | 27 | ' ---------------------------------------------------------------------- 28 | ' COG 0: Variables (Long only) 29 | ' ---------------------------------------------------------------------- 30 | TX_BAUD VAR LONG 31 | 32 | Temp VAR Long 33 | 34 | Value VAR Long 35 | 36 | 37 | 38 | 39 | ' ---------------------------------------------------------------------- 40 | ' COG 0: SUB & FUNC Definitions 41 | ' ---------------------------------------------------------------------- 42 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 43 | LOAD "D:\Propeller\Propeller Programs\Libraries\UTILS_LIB.pbas" 44 | 45 | 46 | ' ---------------------------------------------------------------------- 47 | ' TASK Definitions 48 | ' ---------------------------------------------------------------------- 49 | 50 | 51 | ' ====================================================================== 52 | PROGRAM START 53 | ' ====================================================================== 54 | 55 | START: 56 | 57 | TX_BAUD = Terminal_Baud 58 | PAUSE 5000 59 | SEROUT TX_PIN, T115200, 16 60 | 61 | Main: 62 | 63 | Value = %1010101 64 | 65 | Temp = Copy_Bit Value, 0, Temp, 0 66 | TX_BIN Temp, 32 67 | TX_BYTE 13 68 | TX_BYTE 13 69 | 70 | Temp = Copy_Bit Value, 1, Temp, 0 71 | TX_BIN Temp, 32 72 | TX_BYTE 13 73 | TX_BYTE 13 74 | 75 | Temp = Copy_Bit Value, 4, Temp, 7 76 | TX_BIN Temp, 32 77 | TX_BYTE 13 78 | TX_BYTE 13 79 | 80 | Temp = Copy_Bit Value, 5, Temp, 7 81 | TX_BIN Temp, 32 82 | TX_BYTE 13 83 | TX_BYTE 13 84 | 85 | Temp = Copy_Bit Value, 5, Temp, 7 86 | TX_BIN Temp, 32 87 | TX_BYTE 13 88 | TX_BYTE 13 89 | 90 | Temp = Copy_Bit Value, 2, Temp, 31 91 | TX_BIN Temp, 32 92 | TX_BYTE 13 93 | TX_BYTE 13 94 | 95 | Temp = Copy_Bit %1, 0, Temp, 2 ' Bit is a literal 96 | TX_BIN Temp, 32 97 | TX_BYTE 13 98 | TX_BYTE 13 99 | 100 | Temp = Copy_Bit %0, 0, Temp, 31 ' Bit is a literal 101 | TX_BIN Temp, 32 102 | TX_BYTE 13 103 | TX_BYTE 13 104 | 105 | 106 | 107 | 108 | END 109 | 110 | ' ---------------------------------------------------------------------- 111 | ' COG 0: SUB & FUNC Code 112 | ' ---------------------------------------------------------------------- -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Utilities/Sample Code/BUTTON_Test.pbas: -------------------------------------------------------------------------------- 1 | 2 | DEVICE P8X32A, XTAL1, PLL16X 3 | XIN 5_000_000 4 | 5 | ' ---------------------------------------------------------------------- 6 | ' I/O Pins 7 | ' ---------------------------------------------------------------------- 8 | RX_PIN PIN 31 INPUT 9 | TX_PIN PIN 30 INPUT 10 | 11 | Button_1 PIN 22 INPUT 12 | Button_2 PIN 23 INPUT 13 | 14 | Speaker PIN 24 OUTPUT ' Piezo Buzzer 15 | 16 | 17 | ' ---------------------------------------------------------------------- 18 | ' Constants 19 | ' ---------------------------------------------------------------------- 20 | Terminal_Baud CON 115200 21 | 22 | ' -- TX_Format Constants & Variables --------------- 23 | HOME CON 1 24 | GOTOXY CON 2 25 | BKSP CON 8 26 | TAB CON 9 27 | LF CON 10 28 | CLREOL CON 11 29 | CLRDN CON 12 30 | CR CON 13 31 | GOTOX CON 14 32 | GOTOY CON 15 33 | CLS CON 16 34 | 35 | 36 | 37 | ' ---------------------------------------------------------------------- 38 | ' Data 39 | ' ---------------------------------------------------------------------- 40 | 41 | 42 | ' ---------------------------------------------------------------------- 43 | ' Variables 44 | ' ---------------------------------------------------------------------- 45 | TX_BAUD VAR LONG 46 | 47 | Button_Delay VAR LONG 48 | 49 | Counter VAR LONG 50 | 51 | ' ---------------------------------------------------------------------- 52 | ' SUB & FUNC Definitions 53 | ' ---------------------------------------------------------------------- 54 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB.pbas" 55 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 56 | LOAD "D:\Propeller\Propeller Programs\LIBRARIES\UTILS_LIB.pbas" 57 | 58 | Buttonx FUNC 3 59 | 60 | 61 | ' ---------------------------------------------------------------------- 62 | ' TASK Definitions 63 | ' ---------------------------------------------------------------------- 64 | 65 | ' ====================================================================== 66 | PROGRAM START 67 | ' ====================================================================== 68 | 69 | START: 70 | 71 | COUNTERB 64, Button_1, 0, 1, 0 ' 64 = POS detector, FRQB = 1, PHSB = 0 72 | 73 | TX_BAUD = Terminal_Baud 74 | 75 | DELAY_MS 5000 76 | TX_BYTE CLS 77 | 78 | Counter = 0 79 | 80 | Main: 81 | 82 | TX_STR "Waiting for Button..." 83 | TX_BYTE CR 84 | TX_BYTE CR 85 | 86 | DO 87 | 88 | Button_Delay = Button Button_1, 300, 50 89 | 90 | IF Button_1 = 1 THEN ' Button 1 is Pressed 91 | 92 | INC Counter 93 | TX_DEC Counter 94 | TX_STR " Pressed" 95 | TX_BYTE CR 96 | Piezo Speaker, 300, 135 97 | 98 | DELAY_MS Button_Delay 99 | 100 | ENDIF 101 | 102 | 103 | LOOP UNTIL Button_2 = 1 ' Wait for Button 2 to be Pressed 104 | 105 | Piezo Speaker, 300, 135 106 | TX_BYTE CR 107 | TX_BYTE CR 108 | TX_STR " Finished ... " 109 | 110 | DO 111 | LOOP UNTIL Button_2 = 0 'Wait for the button to be released 112 | 113 | 114 | 115 | END 116 | 117 | ' ---------------------------------------------------------------------- 118 | ' SUB & FUNC Code 119 | ' ---------------------------------------------------------------------- 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Utilities/Sample Code/Copy_Nib_Test.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ---------------------------------------------------------------------- 8 | ' GLOBAL: I/O Pins 9 | ' ---------------------------------------------------------------------- 10 | TX_PIN PIN 30 INPUT 11 | 12 | ' ---------------------------------------------------------------------- 13 | ' GLOBAL: Constants 14 | ' ---------------------------------------------------------------------- 15 | Terminal_Baud CON 115200 16 | 17 | ' ---------------------------------------------------------------------- 18 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 19 | ' ---------------------------------------------------------------------- 20 | 21 | 22 | ' ---------------------------------------------------------------------- 23 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 24 | ' ---------------------------------------------------------------------- 25 | 26 | 27 | ' ---------------------------------------------------------------------- 28 | ' COG 0: Variables (Long only) 29 | ' ---------------------------------------------------------------------- 30 | TX_BAUD VAR LONG 31 | 32 | Temp VAR Long 33 | 34 | Value VAR Long 35 | 36 | 37 | 38 | 39 | ' ---------------------------------------------------------------------- 40 | ' COG 0: SUB & FUNC Definitions 41 | ' ---------------------------------------------------------------------- 42 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 43 | LOAD "D:\Propeller\Propeller Programs\Libraries\UTILS_LIB.pbas" 44 | 45 | 46 | ' ---------------------------------------------------------------------- 47 | ' TASK Definitions 48 | ' ---------------------------------------------------------------------- 49 | 50 | 51 | ' ====================================================================== 52 | PROGRAM START 53 | ' ====================================================================== 54 | 55 | START: 56 | 57 | TX_BAUD = Terminal_Baud 58 | PAUSE 5000 59 | SEROUT TX_PIN, T115200, 16 60 | 61 | Main: 62 | 63 | Value = %1111_1101_0000_1001 64 | 65 | Temp = Copy_Nib Value, 0, Temp, 0 66 | TX_BIN Temp, 32 67 | TX_BYTE 13 68 | TX_BYTE 13 69 | 70 | Temp = Copy_Nib Value, 1, Temp, 0 71 | TX_BIN Temp, 32 72 | TX_BYTE 13 73 | TX_BYTE 13 74 | 75 | Temp = Copy_Nib Value, 3, Temp, 7 76 | TX_BIN Temp, 32 77 | TX_BYTE 13 78 | TX_BYTE 13 79 | 80 | Temp = Copy_Nib Value, 3, Temp, 7 81 | TX_BIN Temp, 32 82 | TX_BYTE 13 83 | TX_BYTE 13 84 | 85 | Temp = Copy_Nib Value, 2, Temp, 7 86 | TX_BIN Temp, 32 87 | TX_BYTE 13 88 | TX_BYTE 13 89 | 90 | Temp = Copy_Nib %1111, 0, Temp, 2 ' Nib is a literal 91 | TX_BIN Temp, 32 92 | TX_BYTE 13 93 | TX_BYTE 13 94 | 95 | Temp = Copy_Nib %0000, 0, Temp, 7 ' NIb is a literal 96 | TX_BIN Temp, 32 97 | TX_BYTE 13 98 | TX_BYTE 13 99 | 100 | Temp = Copy_Nib %0000, 0, Temp, 7 ' NIb is a literal 101 | TX_BIN Temp, 32 102 | TX_BYTE 13 103 | TX_BYTE 13 104 | 105 | 106 | 107 | 108 | END 109 | 110 | ' ---------------------------------------------------------------------- 111 | ' COG 0: SUB & FUNC Code 112 | ' ---------------------------------------------------------------------- -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/TX-RX/Sample Code/Variable_BAUD_TX_RX_Pins_Example.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' GLOBAL: Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ---------------------------------------------------------------------- 8 | ' GLOBAL: I/O Pins 9 | ' ---------------------------------------------------------------------- 10 | ' TX_PIN PIN 30 INPUT 11 | ' RX_PIN PIN 31 INPUT 12 | 13 | ' If you going to use a PIN for an Absolute Pin Value assigment, the Pin Symbol CAN NOT have an "_" in it, e.g. Terminal_TX DOES NOT work !!!! 14 | TerminalTX PIN 30 15 | TerminalRX PIN 31 16 | 17 | LCDTX PIN 1 18 | 19 | DeviceX PIN 2 20 | 21 | ' ---------------------------------------------------------------------- 22 | ' GLOBAL: Constants 23 | ' ---------------------------------------------------------------------- 24 | ' -- !!! You HAVE TO use Variables for the BAUD Rate/s 25 | Terminal_Baud CON 115200 26 | 27 | LCD_Baud CON 9600 28 | 29 | DeviceX_Baud CON 19200 30 | 31 | 32 | ' -- "TX_RX_Format_Lib_.pbas" Constants --------------- 33 | HOME CON 1 34 | CR CON 13 35 | CLS CON 16 36 | 37 | ' ---------------------------------------------------------------------- 38 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 39 | ' ---------------------------------------------------------------------- 40 | 41 | 42 | ' ---------------------------------------------------------------------- 43 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 44 | ' ---------------------------------------------------------------------- 45 | 46 | 47 | ' ---------------------------------------------------------------------- 48 | ' COG 0: Variables (Long only) 49 | ' ---------------------------------------------------------------------- 50 | TX_BAUD VAR LONG 51 | RX_BAUD VAR LONG 52 | 53 | TX_PIN VAR LONG 54 | RX_PIN VAR LONG 55 | 56 | ' ---------------------------------------------------------------------- 57 | ' COG 0: SUB & FUNC Definitions 58 | ' ---------------------------------------------------------------------- 59 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB.pbas" 60 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 61 | 62 | 63 | ' ---------------------------------------------------------------------- 64 | ' TASK Definitions 65 | ' ---------------------------------------------------------------------- 66 | 67 | Task1 TASK 68 | 69 | 70 | ' ====================================================================== 71 | PROGRAM START 72 | ' ====================================================================== 73 | 74 | START: 75 | 76 | TX_BAUD = Terminal_Baud 77 | RX_BAUD = Terminal_Baud 78 | 79 | TX_PIN = #TerminalTX 80 | RX_PIN = #TerminalRX 81 | 82 | DELAY_MS 5000 83 | TX_BYTE CLS 84 | 85 | TX_STR " Writing to Terminal" 86 | 87 | 88 | TX_BAUD = LCD_Baud ' Assign LCD Pin to TX_PIN and LCD Baud to TX_BAUD 89 | TX_PIN = #LCDTX 90 | 91 | ' Do some stuff 92 | 93 | TX_BAUD = DeviceX_Baud ' Assign DeviceX Pin to TX_PIN and DeviceX Baud to TX_BAUD 94 | TX_PIN = #DeviceX 95 | 96 | ' Do some stuff 97 | 98 | 99 | 100 | END 101 | 102 | 103 | ' ---------------------------------------------------------------------- 104 | ' COG 0: SUB & FUNC Code 105 | ' ---------------------------------------------------------------------- 106 | 107 | 108 | -------------------------------------------------------------------------------- /src/_RCTIME.PAS: -------------------------------------------------------------------------------- 1 | Unit _RCTIME; 2 | 3 | {$MODE Delphi} 4 | 5 | // LMM Index 6 | 7 | Interface 8 | 9 | Uses GLOBAL; 10 | 11 | Procedure ProcessRCTime; { pin,state,result } 12 | 13 | Implementation 14 | 15 | Procedure ProcessRCTime; 16 | Begin 17 | If g_iCmdCnt = 6 Then 18 | Begin 19 | If g_asCmdLine[3] <> ',' Then Error(c_iErrorCommaExpected, 3); 20 | If g_asCmdLine[5] <> ',' Then Error(c_iErrorCommaExpected, 5); 21 | If g_apoCmdVars[6]^.eGetType <> e_LongVar Then Error(c_iErrorInvalidParameter, 6); 22 | If g_apoCmdVars[4]^.eGetType <> e_ShortConst Then Error(c_iErrorInvalidParameter, 4) 23 | Else If (g_apoCmdVars[4]^.lGetValue < 0) or (g_apoCmdVars[4]^.lGetValue > 1) Then Error(c_iErrorInvalidParameter, 4); 24 | Case g_apoCmdVars[2]^.eGetType of 25 | e_Pin: 26 | Begin 27 | OutStr(' mov __temp1,'+g_apoCmdVars[2]^.sGetName); 28 | End; 29 | e_ShortConst: 30 | Begin 31 | OutStr(' mov __temp1,#1'); 32 | OutStr(' shl __temp1,#'+g_apoCmdVars[2]^.sGetName); 33 | End; 34 | e_LongVar: 35 | Begin 36 | If g_apoCmdVars[2]^.m_bVarIndex Then 37 | Begin 38 | OutStr(' mov __temp1,#1'); 39 | If g_bLMM Then 40 | Begin 41 | OutStr(' mov __INDEX,#'+g_apoCmdVars[2]^.sGetName); 42 | OutStr(' add __INDEX,'+g_apoCmdVars[2]^.m_sIndex); 43 | OutStr(' jmp #_LMM_MOVS'); 44 | End 45 | Else 46 | Begin 47 | OutStr(' add '+g_apoCmdVars[2]^.m_sIndex+',#'+g_apoCmdVars[2]^.sGetName); 48 | OutStr(' movs $+2,'+g_apoCmdVars[2]^.m_sIndex); 49 | OutStr(' sub '+g_apoCmdVars[2]^.m_sIndex+',#'+g_apoCmdVars[2]^.sGetName); 50 | End; 51 | OutStr(' shl __temp1,0-0'); 52 | End 53 | Else 54 | Begin 55 | OutStr(' mov __temp1,#1'); 56 | OutStr(' shl __temp1,'+g_apoCmdVars[2]^.sGetIndexName); 57 | End; 58 | End 59 | Else Error(c_iErrorInvalidParameter, 2); 60 | End; // Case 61 | OutStr(' andn dira,__temp1'); // Make pin an input 62 | If g_apoCmdVars[6]^.m_bVarIndex Then OutStr(' mov __temp3,#0') 63 | Else OutStr(' mov '+g_apoCmdVars[6]^.sGetName+',#0'); // Zero count 64 | // Measure until pin <> state 65 | OutStr(' mov __temp2,cnt'); 66 | OutStr(' adds __temp2,#'+IntStr(g_lFreq DIV 1000000)); 67 | OutStr(NewLabelStr); 68 | If g_apoCmdVars[6]^.m_bVarIndex Then OutStr(' adds __temp3,#1') 69 | Else OutStr(' adds '+g_apoCmdVars[6]^.sGetName+',#1'); // Zero count 70 | OutStr(' waitcnt __temp2,#'+IntStr(g_lFreq DIV 1000000)); 71 | OutStr(' and __temp1,ina NR, WZ'); 72 | // If pin = state then jmp 73 | If g_apoCmdVars[4]^.lGetValue = 0 Then 74 | Begin 75 | If g_bLMM Then 76 | Begin 77 | OutStr(' IF_Z sub __PC,#(($-'+LabelStr+')*4)+4'); 78 | // OutStr(' IF_Z jmp #_LMM_JUMP'); 79 | // OutStr(' long '+LabelStr+' * 4'); 80 | End 81 | Else OutStr(' IF_Z jmp #'+LabelStr); 82 | End 83 | Else 84 | Begin 85 | If g_bLMM Then 86 | Begin 87 | OutStr(' IF_NZ sub __PC,#(($-'+LabelStr+')*4)+4'); 88 | // OutStr(' IF_NZ jmp #_LMM_JUMP'); 89 | // OutStr(' long '+LabelStr+' * 4'); 90 | End 91 | Else OutStr(' IF_NZ jmp #'+LabelStr); 92 | End; 93 | g_bHandled:=True; 94 | If g_apoCmdVars[6]^.m_bVarIndex Then OutStr(' mov '+g_apoCmdVars[6]^.sGetIndexName+',__temp3'); 95 | VP_WriteVar(6); 96 | End 97 | Else Error(c_iErrorInvalidNumberOfParameters, 0); 98 | End; 99 | 100 | End. 101 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/I2C/Libraries/I2C_LIB_CODE.pbas: -------------------------------------------------------------------------------- 1 | 2 | 3 | ' !!! The {$CODE} Command does NOT work when splittng the SUBS and the CODE !!!!! 4 | ' The {$CODE} Command ONLY works if you "LOAD" the Complete File (inluding the SUBS) in the Main Program 5 | ' 6 | ' LOADing seperate SUBS and CODE files works in the Main Program as well as in Tasks 7 | ' 8 | ' ' ---------------------------------------------------------------------- 9 | ' '{$CODE} 10 | ' ' ---------------------------------------------------------------------- 11 | 12 | ' ---------------------------------------------------------------------- 13 | ' If _param1 = 1 then Read 1 Byte. 14 | ' If _param1 = 2 then Read 2 Bytes (Word). 15 | '{$IFUSED I2C_In} 16 | FUNC I2C_In 17 | 18 | RdByteCnt VAR __param4 19 | 20 | RdByteCnt = __param1 21 | 22 | IF Address_Len > 0 THEN 23 | I2C_START 24 | I2C_WRITE Control_Byte ' Send Control Byte - Write 25 | I2C_ADDRESS 26 | ENDIF 27 | 28 | I2C_START 29 | 30 | __param2 = Control_Byte OR 1 ' Send Control Byte - Read 31 | I2C_WRITE __param2 32 | 33 | IF RdByteCnt = 1 THEN ' Read a Single Byte 34 | __param1 = I2C_READ 1 ' NAK 35 | ELSE ' Read a WORD 36 | __param1 = I2C_READ 0 ' ACK. Read the HighByte 37 | __param4 = __param1 << 8 38 | __param1 = I2C_READ 1 ' NAK. Read the LowByte 39 | __param1 = __param1 OR __param4 40 | ENDIF 41 | 42 | 43 | I2C_STOP 44 | 45 | RETURN __param1 46 | 47 | ENDFUNC 48 | '{$ENDIF} 49 | 50 | 51 | 52 | 53 | ' ---------------------------------------------------------------------- 54 | ' __param1 = Data to Write. 55 | ' If _param2 = 1 then Write 1 Byte. 56 | ' If _param2 = 2 then Write 2 Bytes (Word). 57 | 58 | '{$IFUSED I2C_Out} 59 | SUB I2C_Out 60 | WrData VAR __param3 61 | WrByteCnt VAR __param4 62 | 63 | WrData = __param1 64 | WrByteCnt = __param2 65 | 66 | I2C_START 67 | I2C_WRITE Control_Byte ' Send Control Byte - Write 68 | 69 | IF Address_Len > 0 THEN 70 | I2C_ADDRESS 71 | ENDIF 72 | 73 | IF WrByteCnt = 2 THEN 74 | __param4 = WrData >> 8 ' Write the HIGHBYTE 75 | I2C_WRITE __param4 76 | ENDIF 77 | I2C_WRITE WrData ' Write the LOWBYTE 78 | 79 | I2C_STOP 80 | 81 | ENDSUB 82 | '{$ENDIF} 83 | 84 | 85 | 86 | ' ---------------------------------------------------------------------- 87 | '{$IFUSED I2C_ADDRESS} 88 | SUB I2C_ADDRESS 89 | IF Address_Len = 2 THEN 90 | __param2 = Register_Address >> 8 ' Send Register Address HIGHBYTE 91 | I2C_WRITE __param2 92 | ENDIF 93 | I2C_WRITE Register_Address ' Send Register Address LOWBYTE 94 | ENDSUB 95 | '{$ENDIF} 96 | 97 | 98 | 99 | ' ---------------------------------------------------------------------- 100 | '{$IFUSED I2C_START} 101 | SUB I2C_START 102 | I2CSTART I2C_SDA, I2C_SCL 103 | ENDSUB 104 | '{$ENDIF} 105 | 106 | 107 | 108 | ' ---------------------------------------------------------------------- 109 | '{$IFUSED I2C_READ} 110 | FUNC I2C_READ 111 | ' IF __param1 = 0 ' ACK THEN 112 | ' I2CREAD I2C_SDA, I2C_SCL, __param1, 0 ' ACK 113 | ' ELSE 114 | ' I2CREAD I2C_SDA, I2C_SCL, __param1, 1 ' NAK 115 | ' ENDIF 116 | 117 | I2CREAD I2C_SDA, I2C_SCL, __param2, __param1 118 | RETURN __param2 119 | 120 | ENDFUNC 121 | '{$ENDIF} 122 | 123 | 124 | ' ---------------------------------------------------------------------- 125 | '{$IFUSED I2C_WRITE} 126 | SUB I2C_WRITE 127 | I2CWRITE I2C_SDA, I2C_SCL, __param1 128 | ENDSUB 129 | '{$ENDIF} 130 | 131 | 132 | ' ---------------------------------------------------------------------- 133 | '{$IFUSED I2C_STOP} 134 | SUB I2C_STOP 135 | I2CSTOP I2C_SDA, I2C_SCL 136 | ENDSUB 137 | '{$ENDIF} 138 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Utilities/Sample Code/DCD_Bit_Test.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ---------------------------------------------------------------------- 8 | ' GLOBAL: I/O Pins 9 | ' ---------------------------------------------------------------------- 10 | TX_PIN PIN 30 INPUT 11 | 12 | ' ---------------------------------------------------------------------- 13 | ' GLOBAL: Constants 14 | ' ---------------------------------------------------------------------- 15 | Terminal_Baud CON 115200 16 | 17 | ' ---------------------------------------------------------------------- 18 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 19 | ' ---------------------------------------------------------------------- 20 | 21 | 22 | ' ---------------------------------------------------------------------- 23 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 24 | ' ---------------------------------------------------------------------- 25 | 26 | 27 | ' ---------------------------------------------------------------------- 28 | ' COG 0: Variables (Long only) 29 | ' ---------------------------------------------------------------------- 30 | TX_BAUD VAR LONG 31 | 32 | Row_Code VAR Long 33 | 34 | ' ---------------------------------------------------------------------- 35 | ' COG 0: SUB & FUNC Definitions 36 | ' ---------------------------------------------------------------------- 37 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 38 | LOAD "D:\Propeller\Propeller Programs\Libraries\UTILS_LIB.pbas" 39 | 40 | 41 | ' ---------------------------------------------------------------------- 42 | ' TASK Definitions 43 | ' ---------------------------------------------------------------------- 44 | 45 | 46 | ' ====================================================================== 47 | PROGRAM START 48 | ' ====================================================================== 49 | 50 | START: 51 | 52 | TX_BAUD = Terminal_Baud 53 | PAUSE 5000 54 | SEROUT TX_PIN, T115200, 16 55 | 56 | 57 | Main: 58 | 59 | ' 1). Convert the Value of a Variable to the corresponding Bit Number. The LSB is Bit number 0!. Clear all the other Bits 60 | 61 | Row_Code = 0 62 | 63 | TX_STR "1). Convert the Value of a Variable to the corresponding Bit Number." 64 | TX_BYTE 13 65 | TX_STR "The LSB is Bit number 0!. Clear all the other Bits" 66 | TX_BYTE 13 67 | TX_STR "Binary String Before : " 68 | TX_BIN Row_Code, 16 69 | TX_BYTE 13 70 | 71 | Row_Code = DCD_Bit Row_Code 72 | 73 | TX_STR "Binary String After : " 74 | TX_BIN Row_Code, 16 75 | TX_BYTE 13 76 | TX_BYTE 13 77 | 78 | 79 | ' 2). Convert the Value of a Variable to the corresponding Bit Number BUT with the LSB as Bit number 1!. Clear all the other Bits 80 | 81 | Row_Code = 3 82 | 83 | TX_STR "2). Convert the Value of a Variable to the corresponding Bit Number" 84 | TX_BYTE 13 85 | TX_STR "BUT with the LSB as Bit number 1!. Clear all the other Bits" 86 | TX_BYTE 13 87 | TX_STR "Binary String Before : " 88 | TX_BIN Row_Code, 16 89 | TX_BYTE 13 90 | 91 | Row_Code = Row_Code - 1 ' Subtract 1 to set the LSB as Bit Number 1 92 | Row_Code = DCD_Bit Row_Code 93 | 94 | TX_STR "Binary String After : " 95 | TX_BIN Row_Code, 16 96 | TX_BYTE 13 97 | TX_BYTE 13 98 | 99 | 100 | 101 | 102 | END 103 | 104 | ' ---------------------------------------------------------------------- 105 | ' COG 0: SUB & FUNC Code 106 | ' ---------------------------------------------------------------------- 107 | 108 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Loading Code and Libraries/2. Example_Load_Code_Into_Task.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' GLOBAL: Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ********************************************************* 8 | ' 9 | ' This is an example of how to "LOAD" the Code for a Task. 10 | ' 11 | ' See "TASK Display_DS1302" at the bottom 12 | ' 13 | ' ********************************************************* 14 | 15 | 16 | ' ---------------------------------------------------------------------- 17 | ' GLOBAL: I/O Pins 18 | ' ---------------------------------------------------------------------- 19 | RX_PIN PIN 31 INPUT 20 | TX_PIN PIN 30 INPUT 21 | 22 | Clock PIN 16 LOW 23 | DataIO PIN 17 INPUT 24 | CS1302 PIN 18 LOW 25 | 26 | 27 | ' ---------------------------------------------------------------------- 28 | ' GLOBAL: Constants 29 | ' ---------------------------------------------------------------------- 30 | Terminal_Baud CON 115200 31 | 32 | ' -- TX_Format Constants & Variables --------------- 33 | HOME CON 1 34 | GOTOXY CON 2 35 | BKSP CON 8 36 | TAB CON 9 37 | LF CON 10 38 | CLREOL CON 11 39 | CLRDN CON 12 40 | CR CON 13 41 | GOTOX CON 14 42 | GOTOY CON 15 43 | CLS CON 16 44 | 45 | 46 | CWPr CON $8E ' Write Protect Register 47 | WPr0 CON $00 ' Clear Write Protect 48 | WrBurst CON $BE ' Write Burst Of DataIO 49 | RdBurst CON $BF ' Read Burst Of Data 50 | WrRam CON $C0 ' Write RAM Data 51 | RdRam CON $C1 ' Read RAM Data 52 | 53 | 54 | ' ---------------------------------------------------------------------- 55 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 56 | ' ---------------------------------------------------------------------- 57 | 58 | 59 | ' ---------------------------------------------------------------------- 60 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 61 | ' ---------------------------------------------------------------------- 62 | 63 | 64 | ' ---------------------------------------------------------------------- 65 | ' COG 0: Variables (Long only) 66 | ' ---------------------------------------------------------------------- 67 | 68 | 69 | ' ---------------------------------------------------------------------- 70 | ' COG 0: SUB & FUNC Definitions 71 | ' ---------------------------------------------------------------------- 72 | 73 | 74 | ' ---------------------------------------------------------------------- 75 | ' TASK Definitions 76 | ' ---------------------------------------------------------------------- 77 | Display_DS1302 TASK 78 | 79 | 80 | 81 | ' ====================================================================== 82 | PROGRAM START 83 | ' ====================================================================== 84 | 85 | START: 86 | 87 | COGINIT Display_DS1302, 1 88 | 89 | END 90 | 91 | 92 | ' ---------------------------------------------------------------------- 93 | ' COG 0: SUB & FUNC Code 94 | ' ---------------------------------------------------------------------- 95 | 96 | 97 | 98 | ' ******************************************************************************************* 99 | TASK Display_DS1302 100 | ' ******************************************************************************************* 101 | 102 | LOAD "D:\Propeller\Propeller Programs\Templates\Load Libraries & Code\TASK_Display_DS1302_Code.pbas" 103 | 104 | ENDTASK 105 | ' ******************************************************************************************* 106 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/I2C/Libraries/I2C_LIB.pbas: -------------------------------------------------------------------------------- 1 | 2 | 3 | '*********************************************************************************************************************** 4 | ' 5 | ' 6 | '*********************************************************************************************************************** 7 | 8 | I2C_In FUNC 1 ' If _param1 = 1 then Read 1 Byte. If _param1 = 2 then Read 2 Bytes (Word). 9 | I2C_Out SUB 2 ' __param1 = Data to Write. If _param2 = 1 then Write 1 Byte. If _param2 = 2 then Write 2 Bytes (Word). 10 | 11 | I2C_START SUB 0 12 | I2C_READ FUNC 1 13 | I2C_WRITE SUB 1 14 | I2C_STOP SUB 0 15 | I2C_ADDRESS SUB 0 16 | 17 | ' ---------------------------------------------------------------------- 18 | '{$CODE} 19 | ' ---------------------------------------------------------------------- 20 | 21 | 22 | ' ---------------------------------------------------------------------- 23 | ' If _param1 = 1 then Read 1 Byte. 24 | ' If _param1 = 2 then Read 2 Bytes (Word). 25 | '{$IFUSED I2C_In} 26 | FUNC I2C_In 27 | 28 | RdByteCnt VAR __param4 29 | 30 | RdByteCnt = __param1 31 | 32 | IF Address_Len > 0 THEN 33 | I2C_START 34 | I2C_WRITE Control_Byte ' Send Control Byte - Write 35 | I2C_ADDRESS 36 | ENDIF 37 | 38 | I2C_START 39 | 40 | __param2 = Control_Byte OR 1 ' Send Control Byte - Read 41 | I2C_WRITE __param2 42 | 43 | IF RdByteCnt = 1 THEN ' Read a Single Byte 44 | __param1 = I2C_READ 1 ' NAK 45 | ELSE ' Read a WORD 46 | __param1 = I2C_READ 0 ' ACK. Read the HighByte 47 | __param4 = __param1 << 8 48 | __param1 = I2C_READ 1 ' NAK. Read the LowByte 49 | __param1 = __param1 OR __param4 50 | ENDIF 51 | 52 | 53 | I2C_STOP 54 | 55 | RETURN __param1 56 | 57 | ENDFUNC 58 | '{$ENDIF} 59 | 60 | 61 | 62 | 63 | ' ---------------------------------------------------------------------- 64 | ' __param1 = Data to Write. 65 | ' If _param2 = 1 then Write 1 Byte. 66 | ' If _param2 = 2 then Write 2 Bytes (Word). 67 | 68 | '{$IFUSED I2C_Out} 69 | SUB I2C_Out 70 | WrData VAR __param3 71 | WrByteCnt VAR __param4 72 | 73 | WrData = __param1 74 | WrByteCnt = __param2 75 | 76 | I2C_START 77 | I2C_WRITE Control_Byte ' Send Control Byte - Write 78 | 79 | IF Address_Len > 0 THEN 80 | I2C_ADDRESS 81 | ENDIF 82 | 83 | IF WrByteCnt = 2 THEN 84 | __param4 = WrData >> 8 ' Write the HIGHBYTE 85 | I2C_WRITE __param4 86 | ENDIF 87 | I2C_WRITE WrData ' Write the LOWBYTE 88 | 89 | I2C_STOP 90 | 91 | ENDSUB 92 | '{$ENDIF} 93 | 94 | 95 | 96 | ' ---------------------------------------------------------------------- 97 | '{$IFUSED I2C_ADDRESS} 98 | SUB I2C_ADDRESS 99 | IF Address_Len = 2 THEN 100 | __param2 = Register_Address >> 8 ' Send Register Address HIGHBYTE 101 | I2C_WRITE __param2 102 | ENDIF 103 | I2C_WRITE Register_Address ' Send Register Address LOWBYTE 104 | ENDSUB 105 | '{$ENDIF} 106 | 107 | 108 | 109 | ' ---------------------------------------------------------------------- 110 | '{$IFUSED I2C_START} 111 | SUB I2C_START 112 | I2CSTART I2C_SDA, I2C_SCL 113 | ENDSUB 114 | '{$ENDIF} 115 | 116 | 117 | 118 | ' ---------------------------------------------------------------------- 119 | '{$IFUSED I2C_READ} 120 | FUNC I2C_READ 121 | I2CREAD I2C_SDA, I2C_SCL, __param2, __param1 122 | RETURN __param2 123 | ENDFUNC 124 | '{$ENDIF} 125 | 126 | 127 | ' ---------------------------------------------------------------------- 128 | '{$IFUSED I2C_WRITE} 129 | SUB I2C_WRITE 130 | I2CWRITE I2C_SDA, I2C_SCL, __param1 131 | ENDSUB 132 | '{$ENDIF} 133 | 134 | 135 | ' ---------------------------------------------------------------------- 136 | '{$IFUSED I2C_STOP} 137 | SUB I2C_STOP 138 | I2CSTOP I2C_SDA, I2C_SCL 139 | ENDSUB 140 | '{$ENDIF} 141 | 142 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/JonnyMac/one_wire.lib: -------------------------------------------------------------------------------- 1 | ' ====================================================================== 2 | ' 1-Wire Library for PropBASIC 3 | ' -- by Jon McPhalen 4 | ' -- 28 MAY 2010 5 | ' -- requires PropBASIC 0.98a or later 6 | ' ====================================================================== 7 | 8 | RD_ROM CON $33 ' 1W ROM commands 9 | MATCH_ROM CON $55 10 | SKIP_ROM CON $CC 11 | SRCH_ROM CON $F0 12 | ALARM_SRCH CON $EC 13 | 14 | CVRT_TEMP CON $44 ' DS1822 commands 15 | WR_SPAD CON $4E 16 | RD_SPAD CON $BE 17 | COPY_SPAD CON $48 18 | RD_EE CON $B8 19 | RD_POWER CON $B4 20 | 21 | 22 | ' ---------------------------------------------------------------------- 23 | 24 | OW_READ_SN SUB 1 ' read 1W serial # 25 | OW_WRITE_SN SUB 1 ' write 1W serial # 26 | 27 | OW_RESET FUNC 0 ' reset buss 28 | OW_WRITE SUB 1, 2 ' write bits to buss 29 | OW_READ FUNC 0, 1 ' read bits from buss 30 | 31 | 32 | ' ---------------------------------------------------------------------- 33 | '{$CODE} 34 | ' ---------------------------------------------------------------------- 35 | 36 | ' Use: OW_READ_SN snAddr 37 | ' -- reads 1-wire serial number from buss 38 | ' -- snAddr is address of 8-byte DATA table 39 | 40 | '{$IFUSED OW_READ_SN} 41 | SUB OW_READ_SN 42 | 43 | rsnIn VAR __param1 44 | rsnAddr VAR __param3 45 | rsnIdx VAR __param4 46 | 47 | rsnAddr = __param1 ' save address 48 | 49 | OW_RESET 50 | OW_WRITE RD_ROM 51 | 52 | FOR rsnIdx = 0 TO 7 53 | rsnIn = OW_READ ' read byte from 1W 54 | WRBYTE rsnAddr, rsnIn ' save byte 55 | INC rsnAddr ' point to next 56 | NEXT 57 | 58 | ENDSUB 59 | '{$ENDIF} 60 | 61 | ' ---------------------------------------------------------------------- 62 | 63 | ' Use OW_WRITE_SN snAddr 64 | ' -- writes 1-wire serial number to buss 65 | ' -- snAddr is address of 8-byte DATA table 66 | 67 | '{$IFUSED OW_WRITE_SN} 68 | SUB OW_WRITE_SN 69 | 70 | wsnOut VAR __param1 71 | wsnAddr VAR __param3 72 | wsnIdx VAR __param4 73 | 74 | wsnAddr = __param1 ' save address 75 | 76 | OW_RESET 77 | OW_WRITE MATCH_ROM 78 | 79 | FOR wsnIdx = 0 TO 7 80 | RDBYTE wsnAddr, wsnOut ' get byte 81 | OW_WRITE wsnOut ' write to 1W buss 82 | INC wsnAddr ' point to next 83 | NEXT 84 | 85 | ENDSUB 86 | '{$ENDIF} 87 | 88 | ' ---------------------------------------------------------------------- 89 | 90 | ' Use: {result =} OW_RESET 91 | ' -- resets 1-Wire buss; can return 92 | ' -- requires PIN defintion: DQ 93 | 94 | '{$IFUSED OW_RESET} 95 | FUNC OW_RESET 96 | 97 | OWRESET DQ, __param1 98 | RETURN __param1 99 | 100 | ENDFUNC 101 | '{$ENDIF} 102 | 103 | ' ---------------------------------------------------------------------- 104 | 105 | ' Use: OW_WRITE value {, bits} 106 | ' -- writes byte to 1-Wire buss 107 | ' -- requires PIN defintion: DQ 108 | 109 | '{$IFUSED OW_WRITE} 110 | SUB OW_WRITE 111 | 112 | IF __paramcnt = 1 THEN 113 | __param2 = 8 114 | ENDIF 115 | 116 | OWWRITE DQ, __param1\__param2 117 | 118 | ENDSUB 119 | '{$ENDIF} 120 | 121 | ' ---------------------------------------------------------------------- 122 | 123 | ' Use: result = OW_READ {, bits } 124 | ' -- read byte from 1-Wire buss 125 | ' -- requires PIN defintion: DQ 126 | 127 | '{$IFUSED OW_READ} 128 | FUNC OW_READ 129 | 130 | IF __paramcnt = 0 THEN 131 | __param2 = 8 132 | ELSE 133 | __param2 = __param1 134 | ENDIF 135 | 136 | OWREAD DQ, __param1\__param2 137 | RETURN __param1 138 | 139 | ENDFUNC 140 | '{$ENDIF} 141 | 142 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/I2C/Sample Code/I2C_Write_Read_Example.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' GLOBAL: Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | 8 | ' ---------------------------------------------------------------------- 9 | ' GLOBAL: I/O Pins 10 | ' ---------------------------------------------------------------------- 11 | TX_PIN PIN 30 INPUT 12 | RX_PIN PIN 31 INPUT 13 | 14 | ' *********************************************************** 15 | ' These Pin Labels are HARDCODED in I2C_LIB.pbas 16 | I2C_SDA PIN 0 INPUT 17 | I2C_SCL PIN 1 INPUT 18 | ' *********************************************************** 19 | 20 | ' ---------------------------------------------------------------------- 21 | ' GLOBAL: Constants 22 | ' ---------------------------------------------------------------------- 23 | ' -- !!! You HAVE TO use Variables for the BAUD Rate/s 24 | Terminal_Baud CON 115200 25 | 26 | ' -- "TX_RX_Format_Lib_.pbas" Constants --------------- 27 | HOME CON 1 28 | CR CON 13 29 | CLS CON 16 30 | 31 | ' -- MCP23008 Control Register Addresses 32 | IODIR CON $00 33 | GPIO CON $09 34 | 35 | 36 | ' ---------------------------------------------------------------------- 37 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 38 | ' ---------------------------------------------------------------------- 39 | 40 | 41 | ' ---------------------------------------------------------------------- 42 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 43 | ' ---------------------------------------------------------------------- 44 | 45 | 46 | ' ---------------------------------------------------------------------- 47 | ' COG 0: Variables (Long only) 48 | ' ---------------------------------------------------------------------- 49 | ' *********************************************************** 50 | ' These Variables are HARDCODED in I2C_LIB.pbas 51 | Register_Address VAR LONG 52 | Address_Len VAR LONG 53 | Control_Byte VAR LONG 54 | ' *********************************************************** 55 | 56 | TX_BAUD VAR LONG 57 | RX_BAUD VAR LONG 58 | 59 | Temp VAR LONG 60 | 61 | Counter VAR LONG 62 | 63 | ' ---------------------------------------------------------------------- 64 | ' COG 0: SUB & FUNC Definitions 65 | ' ---------------------------------------------------------------------- 66 | LOAD "D:\Propeller\Propeller Programs\Libraries\I2C_LIB.pbas" 67 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 68 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB.pbas" 69 | 70 | 71 | 72 | ' ---------------------------------------------------------------------- 73 | ' TASK Definitions 74 | ' ---------------------------------------------------------------------- 75 | 76 | 77 | ' ====================================================================== 78 | PROGRAM START 79 | ' ====================================================================== 80 | 81 | START: 82 | 83 | TX_BAUD = Terminal_Baud 84 | RX_BAUD = Terminal_Baud 85 | 86 | DELAY_MS 100 87 | TX_BYTE CLS 88 | 89 | Control_Byte = %0100_0000 ' Control Byte for I2C WRITE. Device Address = 0 90 | Address_Len = 1 ' The device Address is only 1 Byte. 91 | ' For devices with Word length Adresses, e.g. EEPROM devices, Address_Len = 2 92 | ' For devices which do not use an Address, e.g. PCF8574, Address_len = 0 (ZERO) 93 | 94 | ' -- Write the Pin Directions to the IODIR Register ---------------- 95 | Register_Address = IODIR 96 | Temp = %00000000 ' All Pins are Outputs 97 | I2C_Out Temp, 1 ' Write 1 Byte. To Write a WORD the syntax = I2C_Out Temp, 2 98 | 99 | 100 | Register_Address = GPIO 101 | 102 | 103 | FOR Counter = 1 TO 255 104 | Temp = Counter 105 | I2C_Out Temp, 1 ' Write 1 Byte 106 | DELAY_MS 100 107 | NEXT 108 | 109 | FOR Counter = 1 TO 255 110 | Temp = Counter 111 | Temp = I2C_In 1 ' Read 1 Byte. To Read a WORD the syntax = Temp = I2C_In 2 112 | DELAY_MS 100 113 | TX_DEC Counter 114 | TX_STR " : " 115 | TX_BYTE Temp 116 | TX_BYTE CR 117 | NEXT 118 | 119 | END 120 | 121 | 122 | ' ---------------------------------------------------------------------- 123 | ' COG 0: SUB & FUNC Code 124 | ' ---------------------------------------------------------------------- 125 | 126 | 127 | 128 | 129 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/JonnyMac/sircs.lib: -------------------------------------------------------------------------------- 1 | ' ================================================================================================= 2 | ' SIRCS Library for PropBASIC 3 | ' -- by Jon McPhalen 4 | ' -- 23 MAY 2010 5 | ' -- requires PropBASIC 0.98a or later 6 | ' ================================================================================================= 7 | 8 | ' NOTE: Uses CTRA and CTRA 9 | 10 | 11 | POS_DETECT CON 64 12 | NEG_DETECT CON 96 13 | FREE_RUN CON 248 14 | 15 | '{$IFFREQ < 80_000_000} 16 | '{$ERROR SIRCS library designed for 80 or 100 MHz} 17 | '{$ENDIF} 18 | 19 | '{$IFFREQ = 80_000_000} 20 | 21 | MS_044 CON 3_520_000 ' 44ms @ 80MHz 22 | BIT_S CON 172_800 ' 90% of 2.4ms 23 | BIT_1 CON 86_400 ' 90% of 1.2ms 24 | BIT_0 CON 43_200 ' 90% of 0.6ms 25 | 26 | '{$ELSE} 27 | 28 | MS_044 CON 4_400_000 ' 44ms @ 100MHz 29 | BIT_S CON 216_000 ' 90% of 2.4ms 30 | BIT_1 CON 108_000 ' 90% of 1.2ms 31 | BIT_0 CON 54_000 ' 90% of 0.6ms 32 | 33 | '{$ENDIF} 34 | 35 | ' ------------------------------------------------------------------------------------------------- 36 | 37 | GET_SIRCS FUNC 1 ' SIRCS + bit count 38 | 39 | 40 | ' ------------------------------------------------------------------------------------------------- 41 | '{$CODE} 42 | ' ------------------------------------------------------------------------------------------------- 43 | 44 | ' Use: variable = GET_SIRCS pin# 45 | ' -- waits for and returns SIRCS code and bit count 46 | ' -- PropBASIC adaptation of my Spin/PASM object in Jan 2010 Nuts & Volts 47 | 48 | '{$IFUSED GET_SIRCS} 49 | FUNC GET_SIRCS 50 | 51 | irPin VAR __param2 ' pin # (not mask) 52 | irCode VAR __param3 53 | irBits VAR __param4 54 | 55 | irPin = __param1 ' capture pin # 56 | 57 | COUNTERA NEG_DETECT, irPin, 0, 1 ' set for pulse timing 58 | COUNTERB FREE_RUN, 0, 0, 1 ' set for frame timing 59 | 60 | ASM 61 | mov __temp1, #1 ' convert pin to mask 62 | shl __temp1, irPin 63 | mov irPin, __temp1 64 | 65 | waitstart waitpeq irPin, irPin ' wait for high 66 | mov phsa, #0 ' start bit timer 67 | waitpne irPin, irPin ' wait for low 68 | mov phsb, #0 ' start frame timer 69 | waitpeq irPin, irPin ' wait for high 70 | mov __temp1, phsa ' capture phsa 71 | cmp __temp1, BIT_S wc, wz ' valid start bit? 72 | if_b jmp #waitstart ' try again if no 73 | 74 | mov irCode, #0 75 | mov irBits, #0 ' reset bit count 76 | 77 | checkframe mov __temp1, phsb ' capture phsb 78 | cmp __temp1, MS_044 wc, wz ' check frame timer 79 | if_ae jmp #irdone ' abort @44ms 80 | 81 | waitbit test irPin, ina wz ' look for new bit 82 | if_nz jmp #checkframe ' check for end if no bit 83 | 84 | measurebit mov phsa, #0 ' resstart bit timer 85 | waitpeq irPin, irPin ' wait for high (end of bit) 86 | cmp BIT_1, phsa wc ' ir bit --> C 87 | rcr irCode, #1 ' C --> irwork.31 88 | 89 | add irBits, #1 ' inc bit count 90 | cmp irBits, #20 wc ' at max? 91 | if_b jmp #checkframe ' keep scanning if no 92 | 93 | irdone mov __temp1, #32 94 | sub __temp1, irBits 95 | shr irCode, __temp1 ' right align ir code 96 | 97 | ENDASM 98 | RETURN irCode, irBits 99 | 100 | ENDFUNC 101 | '{$ENDIF} 102 | 103 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Program Templates/Example_Template_Without_Tasks.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' GLOBAL: Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ---------------------------------------------------------------------- 8 | ' GLOBAL: I/O Pins 9 | ' ---------------------------------------------------------------------- 10 | 11 | ' -- You can Use Pins (e.g. TX_PIN and RX_PIN) Directly like this instead of Variables 12 | ' TX_PIN PIN 30 INPUT 13 | ' RX_PIN PIN 31 INPUT 14 | 15 | 16 | 17 | ' ---------------------------------------------------------------------- 18 | ' GLOBAL: Constants 19 | ' ---------------------------------------------------------------------- 20 | 21 | ' -- !!! You HAVE TO use Variables for the BAUD Rate/s 22 | Terminal_Baud CON 115200 23 | 24 | EEPROM_I2C_SDA CON 10 25 | EEPROM_I2C_SCL CON 11 26 | 27 | Terminal_TX CON 30 28 | Terminal_RX CON 31 29 | 30 | Eyes_LCD_TX CON 15 31 | Mouth_LCD_TX CON 12 32 | 33 | ' -- "TX_RX_Format_Lib_.pbas" Constants --------------- 34 | HOME CON 1 35 | GOTOXY CON 2 36 | CRSRLF CON 3 37 | CRSRRT CON 4 38 | CRSRUP CON 5 39 | CRSRN CON 6 40 | BEEP CON 7 41 | BKSP CON 8 42 | TAB CON 9 43 | LF CON 10 44 | CLREOL CON 11 45 | CLRDN CON 12 46 | CR CON 13 47 | GOTOX CON 14 48 | GOTOY CON 15 49 | CLS CON 16 50 | 51 | 52 | 53 | ' ---------------------------------------------------------------------- 54 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 55 | ' ---------------------------------------------------------------------- 56 | Mouth_Control HUB Byte 57 | 58 | 59 | 60 | ' ---------------------------------------------------------------------- 61 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 62 | ' ---------------------------------------------------------------------- 63 | Menu01 DATA "> Enter 2 digit year, e.g. '05' = 2005:", CR, CR, 0 64 | 65 | 66 | ' ---------------------------------------------------------------------- 67 | ' COG 0: Variables (Long only) 68 | ' ---------------------------------------------------------------------- 69 | TX_BAUD VAR LONG 70 | RX_BAUD VAR LONG 71 | 72 | TX_PIN VAR Long 73 | RX_PIN VAR Long 74 | 75 | I2C_SDA VAR Long 76 | I2C_SCL VAR Long 77 | 78 | Key VAR Long 79 | 80 | 81 | ' *********************************************************** 82 | ' These Variables are HARDCODED in I2C_LIB.pbas 83 | Register_Address VAR LONG 84 | Address_Len VAR LONG 85 | Control_Byte VAR LONG 86 | ' *********************************************************** 87 | 88 | 89 | ' ---------------------------------------------------------------------- 90 | ' COG 0: SUB & FUNC Definitions 91 | ' ---------------------------------------------------------------------- 92 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB.pbas" 93 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 94 | LOAD "D:\Propeller\Propeller Programs\Libraries\I2C_LIB.pbas" 95 | LOAD "D:\Propeller\Propeller Programs\Libraries\UTILS_LIB.pbas" 96 | 97 | 98 | ' -- Use "Ser_In" if "RX_BYTE" or "RX_DEC 1" makes the code too long 99 | Ser_In FUNC 0 100 | 101 | Check_Eye_Ack SUB 0 102 | 103 | 104 | ' ---------------------------------------------------------------------- 105 | ' TASK Definitions 106 | ' ---------------------------------------------------------------------- 107 | 108 | 109 | ' ====================================================================== 110 | PROGRAM START 111 | ' ====================================================================== 112 | 113 | START: 114 | 115 | TX_BAUD = Terminal_Baud 116 | RX_BAUD = Terminal_Baud 117 | 118 | TX_PIN = Terminal_TX 119 | RX_PIN = Terminal_RX 120 | 121 | I2C_SDA = EEPROM_I2C_SDA 122 | I2C_SCL = EEPROM_I2C_SCL 123 | 124 | DELAY_MS 5000 125 | TX_BYTE CLS 126 | 127 | Main: 128 | 129 | Key = Ser_In 130 | IF Key = "1" THEN 131 | ' Write_Data 132 | ELSEIF Key = "2" THEN 133 | ' Read_Data 134 | ENDIF 135 | 136 | 137 | DO 138 | 139 | 140 | LOOP 141 | 142 | END 143 | 144 | 145 | ' ---------------------------------------------------------------------- 146 | ' COG 0: SUB & FUNC Code 147 | ' ---------------------------------------------------------------------- 148 | 149 | ' ---------------------------------------------------------------------- 150 | FUNC Ser_In 151 | SERIN RX_PIN, T115200, __param1 152 | RETURN __param1 153 | ENDFUNC 154 | 155 | 156 | ' ---------------------------------------------------------------------- 157 | SUB Check_Eye_Ack 158 | __param1 = 0 159 | DO 160 | 161 | LOOP UNTIL __param1 = 1 162 | ENDSUB 163 | 164 | 165 | 166 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Loading Code and Libraries/1. Example_Load_Libraries_Into_Tasks.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' GLOBAL: Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ---------------------------------------------------------------------- 8 | ' GLOBAL: I/O Pins 9 | ' ---------------------------------------------------------------------- 10 | TX_PIN PIN 30 INPUT 11 | RX_PIN PIN 31 INPUT 12 | 13 | ' ---------------------------------------------------------------------- 14 | ' GLOBAL: Constants 15 | ' ---------------------------------------------------------------------- 16 | ' -- !!! You HAVE TO use Variables for the BAUD Rate/s 17 | Terminal_Baud CON 115200 18 | 19 | ' -- "TX_RX_Format_Lib_.pbas" Constants --------------- 20 | HOME CON 1 21 | CR CON 13 22 | CLS CON 16 23 | 24 | ' ---------------------------------------------------------------------- 25 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 26 | ' ---------------------------------------------------------------------- 27 | 28 | 29 | ' ---------------------------------------------------------------------- 30 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 31 | ' ---------------------------------------------------------------------- 32 | 33 | 34 | ' ---------------------------------------------------------------------- 35 | ' COG 0: Variables (Long only) 36 | ' ---------------------------------------------------------------------- 37 | TX_BAUD VAR LONG 38 | RX_BAUD VAR LONG 39 | 40 | ' ---------------------------------------------------------------------- 41 | ' COG 0: SUB & FUNC Definitions 42 | ' ---------------------------------------------------------------------- 43 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB.pbas" 44 | 45 | ' ---------------------------------------------------------------------- 46 | ' TASK Definitions 47 | ' ---------------------------------------------------------------------- 48 | 49 | Task1 TASK 50 | 51 | 52 | ' ====================================================================== 53 | PROGRAM START 54 | ' ====================================================================== 55 | 56 | START: 57 | 58 | TX_BAUD = Terminal_Baud 59 | RX_BAUD = Terminal_Baud 60 | 61 | DELAY_MS 5000 62 | TX_BYTE CLS 63 | 64 | COGSTART Task1 65 | 66 | 67 | END 68 | 69 | 70 | ' ---------------------------------------------------------------------- 71 | ' COG 0: SUB & FUNC Code 72 | ' ---------------------------------------------------------------------- 73 | 74 | 75 | 76 | 77 | ' ******************************************************************************************* 78 | TASK Task1 79 | ' ******************************************************************************************* 80 | 81 | ' ---------------------------------------------------------------------- 82 | ' TASK COG: I/O Pins 83 | ' ---------------------------------------------------------------------- 84 | 85 | ' ---------------------------------------------------------------------- 86 | ' TASK COG: Constants 87 | ' ---------------------------------------------------------------------- 88 | 89 | ' ---------------------------------------------------------------------- 90 | ' TASK COG: Variables (Long only) 91 | ' ---------------------------------------------------------------------- 92 | TX_BAUD VAR LONG 93 | RX_BAUD VAR LONG 94 | 95 | 96 | ' ---------------------------------------------------------------------- 97 | ' TASK COG: SUB & FUNC Definitions 98 | ' ---------------------------------------------------------------------- 99 | ' !!! The LOAD SUB Commands for Libraries MUST BE BEFORE your own SUB and FUNC Declarations 100 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB_SUBS.pbas" 101 | 102 | 103 | Subroutine_1 SUB 0 104 | 105 | Function_1 FUNC 0 106 | 107 | 108 | ' ---------------------------------------------------------------------- 109 | ' Main Task Code 110 | ' ---------------------------------------------------------------------- 111 | MAIN: 112 | 113 | TX_BAUD = Terminal_Baud 114 | RX_BAUD = Terminal_Baud 115 | 116 | DELAY_MS 5000 117 | TX_BYTE CLS 118 | 119 | 120 | ' ---------------------------------------------------------------------- 121 | ' TASK COG: SUB & FUNCTION Code 122 | ' ---------------------------------------------------------------------- 123 | 124 | SUB Subroutine_1 125 | 126 | ' Do some stuff 127 | 128 | ENDSUB 129 | 130 | 131 | 132 | 133 | FUNC Function_1 134 | 135 | ' DO some stuff 136 | 137 | ' RETURN __paramx 138 | 139 | ENDFUNC 140 | 141 | 142 | 143 | 144 | 145 | ' !!! The LOAD CODE Commands for Libraries MUST BE AFTER your own SUB and FUNC Declarations, i.e. just before "ENDTASK" 146 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB_CODE.pbas" 147 | ENDTASK 148 | ' ******************************************************************************************* 149 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Program Templates/Blank_Template_With_Task.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' GLOBAL: Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ---------------------------------------------------------------------- 8 | ' GLOBAL: I/O Pins 9 | ' ---------------------------------------------------------------------- 10 | TX_PIN PIN 30 INPUT 11 | RX_PIN PIN 31 INPUT 12 | 13 | ' ---------------------------------------------------------------------- 14 | ' GLOBAL: Constants 15 | ' ---------------------------------------------------------------------- 16 | ' -- !!! You HAVE TO use Variables for the BAUD Rate/s 17 | Terminal_Baud CON 115200 18 | 19 | ' -- "TX_RX_Format_Lib_.pbas" Constants --------------- 20 | HOME CON 1 21 | CR CON 13 22 | CLS CON 16 23 | 24 | ' ---------------------------------------------------------------------- 25 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 26 | ' ---------------------------------------------------------------------- 27 | 28 | 29 | ' ---------------------------------------------------------------------- 30 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 31 | ' ---------------------------------------------------------------------- 32 | 33 | 34 | ' ---------------------------------------------------------------------- 35 | ' COG 0: Variables (Long only) 36 | ' ---------------------------------------------------------------------- 37 | TX_BAUD VAR LONG 38 | RX_BAUD VAR LONG 39 | 40 | ' ---------------------------------------------------------------------- 41 | ' COG 0: SUB & FUNC Definitions 42 | ' ---------------------------------------------------------------------- 43 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB.pbas" 44 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 45 | LOAD "D:\Propeller\Propeller Programs\Libraries\I2C_LIB.pbas" 46 | LOAD "D:\Propeller\Propeller Programs\Libraries\UTILS_LIB.pbas" 47 | 48 | 49 | ' ---------------------------------------------------------------------- 50 | ' TASK Definitions 51 | ' ---------------------------------------------------------------------- 52 | 53 | Task1 TASK 54 | 55 | 56 | ' ====================================================================== 57 | PROGRAM START 58 | ' ====================================================================== 59 | 60 | START: 61 | 62 | TX_BAUD = Terminal_Baud 63 | RX_BAUD = Terminal_Baud 64 | 65 | DELAY_MS 5000 66 | TX_BYTE CLS 67 | 68 | COGSTART Task1 69 | ' COGINIT Task1, 1 70 | 71 | 72 | END 73 | 74 | 75 | ' ---------------------------------------------------------------------- 76 | ' COG 0: SUB & FUNC Code 77 | ' ---------------------------------------------------------------------- 78 | 79 | 80 | 81 | 82 | ' ******************************************************************************************* 83 | TASK Task1 84 | ' ******************************************************************************************* 85 | 86 | ' ---------------------------------------------------------------------- 87 | ' TASK COG: I/O Pins 88 | ' ---------------------------------------------------------------------- 89 | 90 | ' ---------------------------------------------------------------------- 91 | ' TASK COG: Constants 92 | ' ---------------------------------------------------------------------- 93 | 94 | ' ---------------------------------------------------------------------- 95 | ' TASK COG: Variables (Long only) 96 | ' ---------------------------------------------------------------------- 97 | TX_BAUD VAR LONG 98 | RX_BAUD VAR LONG 99 | 100 | 101 | ' ---------------------------------------------------------------------- 102 | ' TASK COG: SUB & FUNC Definitions 103 | ' ---------------------------------------------------------------------- 104 | ' !!! The LOAD SUB Commands MUST BE BEFORE all the other SUB and FUNC Declarations 105 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB_SUBS.pbas" 106 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB_SUBS.pbas" 107 | 108 | 109 | 110 | ' ---------------------------------------------------------------------- 111 | ' Main Task Code 112 | ' ---------------------------------------------------------------------- 113 | MAIN: 114 | 115 | TX_BAUD = Terminal_Baud 116 | RX_BAUD = Terminal_Baud 117 | 118 | DELAY_MS 5000 119 | TX_BYTE CLS 120 | 121 | 122 | ' ---------------------------------------------------------------------- 123 | ' TASK COG: SUB & FUNCTION Code 124 | ' ---------------------------------------------------------------------- 125 | 126 | 127 | 128 | ' !!! The LOAD CODE Commands MUST BE AFTER all the other SUB and FUNC Declarations, i.e. just before "ENDTASK" 129 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB_CODE.pbas" 130 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB_CODE.pbas" 131 | ENDTASK 132 | ' ******************************************************************************************* 133 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Program Templates/Blank_Template_With_Task_Variable_TX_RX_Pins.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' GLOBAL: Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ---------------------------------------------------------------------- 8 | ' GLOBAL: I/O Pins 9 | ' ---------------------------------------------------------------------- 10 | ' TX_PIN PIN 30 INPUT 11 | ' RX_PIN PIN 31 INPUT 12 | 13 | TerminalTX PIN 30 ' If you going to use a PIN for an Absolute Pin Value assigment, the Pin Symbol CAN NOT have an "_" in it, 14 | ' e.g. Terminal_TX DOES NOT work !!!! 15 | TerminalRX PIN 31 16 | 17 | ' ---------------------------------------------------------------------- 18 | ' GLOBAL: Constants 19 | ' ---------------------------------------------------------------------- 20 | ' -- !!! You HAVE TO use Variables for the BAUD Rate/s 21 | Terminal_Baud CON 115200 22 | 23 | 24 | ' -- "TX_RX_Format_Lib_.pbas" Constants --------------- 25 | HOME CON 1 26 | CR CON 13 27 | CLS CON 16 28 | 29 | ' ---------------------------------------------------------------------- 30 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 31 | ' ---------------------------------------------------------------------- 32 | 33 | 34 | ' ---------------------------------------------------------------------- 35 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 36 | ' ---------------------------------------------------------------------- 37 | 38 | 39 | ' ---------------------------------------------------------------------- 40 | ' COG 0: Variables (Long only) 41 | ' ---------------------------------------------------------------------- 42 | TX_BAUD VAR LONG 43 | RX_BAUD VAR LONG 44 | 45 | TX_PIN VAR LONG 46 | RX_PIN VAR LONG 47 | 48 | ' ---------------------------------------------------------------------- 49 | ' COG 0: SUB & FUNC Definitions 50 | ' ---------------------------------------------------------------------- 51 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB.pbas" 52 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 53 | LOAD "D:\Propeller\Propeller Programs\Libraries\I2C_LIB.pbas" 54 | LOAD "D:\Propeller\Propeller Programs\Libraries\UTILS_LIB.pbas" 55 | 56 | 57 | ' ---------------------------------------------------------------------- 58 | ' TASK Definitions 59 | ' ---------------------------------------------------------------------- 60 | 61 | Task1 TASK 62 | 63 | 64 | ' ====================================================================== 65 | PROGRAM START 66 | ' ====================================================================== 67 | 68 | START: 69 | 70 | TX_BAUD = Terminal_Baud 71 | RX_BAUD = Terminal_Baud 72 | 73 | TX_PIN = #TerminalTX ' If you use an Absolute Pin Value assigment like this, the Pin Symbol CAN NOT have an "_" in it, e.g. Terminal_TX DOES NOT work !!!! 74 | RX_PIN = #TerminalRX 75 | 76 | DELAY_MS 5000 77 | TX_BYTE CLS 78 | 79 | COGSTART Task1 80 | ' COGINIT Task1, 1 81 | 82 | 83 | END 84 | 85 | 86 | ' ---------------------------------------------------------------------- 87 | ' COG 0: SUB & FUNC Code 88 | ' ---------------------------------------------------------------------- 89 | 90 | 91 | 92 | 93 | ' ******************************************************************************************* 94 | TASK Task1 95 | ' ******************************************************************************************* 96 | 97 | ' ---------------------------------------------------------------------- 98 | ' TASK COG: I/O Pins 99 | ' ---------------------------------------------------------------------- 100 | 101 | ' ---------------------------------------------------------------------- 102 | ' TASK COG: Constants 103 | ' ---------------------------------------------------------------------- 104 | 105 | ' ---------------------------------------------------------------------- 106 | ' TASK COG: Variables (Long only) 107 | ' ---------------------------------------------------------------------- 108 | TX_BAUD VAR LONG 109 | RX_BAUD VAR LONG 110 | 111 | TX_PIN VAR LONG 112 | RX_PIN VAR LONG 113 | 114 | 115 | ' ---------------------------------------------------------------------- 116 | ' TASK COG: SUB & FUNC Definitions 117 | ' ---------------------------------------------------------------------- 118 | ' !!! The LOAD SUB Commands MUST BE BEFORE all the other SUB and FUNC Declarations 119 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB_SUBS.pbas" 120 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB_SUBS.pbas" 121 | 122 | 123 | 124 | ' ---------------------------------------------------------------------- 125 | ' Main Task Code 126 | ' ---------------------------------------------------------------------- 127 | MAIN: 128 | 129 | TX_BAUD = Terminal_Baud 130 | RX_BAUD = Terminal_Baud 131 | 132 | DELAY_MS 5000 133 | TX_BYTE CLS 134 | 135 | 136 | ' ---------------------------------------------------------------------- 137 | ' TASK COG: SUB & FUNCTION Code 138 | ' ---------------------------------------------------------------------- 139 | 140 | 141 | 142 | ' !!! The LOAD CODE Commands MUST BE AFTER all the other SUB and FUNC Declarations, i.e. just before "ENDTASK" 143 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB_CODE.pbas" 144 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB_CODE.pbas" 145 | ENDTASK 146 | ' ******************************************************************************************* 147 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/TX-RX/Sample Code/Blank_Template_With_Task_Variable_TX_RX_Pins.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' GLOBAL: Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ---------------------------------------------------------------------- 8 | ' GLOBAL: I/O Pins 9 | ' ---------------------------------------------------------------------- 10 | ' TX_PIN PIN 30 INPUT 11 | ' RX_PIN PIN 31 INPUT 12 | 13 | TerminalTX PIN 30 ' If you going to use a PIN for an Absolute Pin Value assigment, the Pin Symbol CAN NOT have an "_" in it, 14 | ' e.g. Terminal_TX DOES NOT work !!!! 15 | TerminalRX PIN 31 16 | 17 | ' ---------------------------------------------------------------------- 18 | ' GLOBAL: Constants 19 | ' ---------------------------------------------------------------------- 20 | ' -- !!! You HAVE TO use Variables for the BAUD Rate/s 21 | Terminal_Baud CON 115200 22 | 23 | 24 | ' -- "TX_RX_Format_Lib_.pbas" Constants --------------- 25 | HOME CON 1 26 | CR CON 13 27 | CLS CON 16 28 | 29 | ' ---------------------------------------------------------------------- 30 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 31 | ' ---------------------------------------------------------------------- 32 | 33 | 34 | ' ---------------------------------------------------------------------- 35 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 36 | ' ---------------------------------------------------------------------- 37 | 38 | 39 | ' ---------------------------------------------------------------------- 40 | ' COG 0: Variables (Long only) 41 | ' ---------------------------------------------------------------------- 42 | TX_BAUD VAR LONG 43 | RX_BAUD VAR LONG 44 | 45 | TX_PIN VAR LONG 46 | RX_PIN VAR LONG 47 | 48 | ' ---------------------------------------------------------------------- 49 | ' COG 0: SUB & FUNC Definitions 50 | ' ---------------------------------------------------------------------- 51 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB.pbas" 52 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 53 | LOAD "D:\Propeller\Propeller Programs\Libraries\I2C_LIB.pbas" 54 | LOAD "D:\Propeller\Propeller Programs\Libraries\UTILS_LIB.pbas" 55 | 56 | 57 | ' ---------------------------------------------------------------------- 58 | ' TASK Definitions 59 | ' ---------------------------------------------------------------------- 60 | 61 | Task1 TASK 62 | 63 | 64 | ' ====================================================================== 65 | PROGRAM START 66 | ' ====================================================================== 67 | 68 | START: 69 | 70 | TX_BAUD = Terminal_Baud 71 | RX_BAUD = Terminal_Baud 72 | 73 | TX_PIN = #TerminalTX ' If you use an Absolute Pin Value assigment like this, the Pin Symbol CAN NOT have an "_" in it, e.g. Terminal_TX DOES NOT work !!!! 74 | RX_PIN = #TerminalRX 75 | 76 | DELAY_MS 5000 77 | TX_BYTE CLS 78 | 79 | COGSTART Task1 80 | ' COGINIT Task1, 1 81 | 82 | 83 | END 84 | 85 | 86 | ' ---------------------------------------------------------------------- 87 | ' COG 0: SUB & FUNC Code 88 | ' ---------------------------------------------------------------------- 89 | 90 | 91 | 92 | 93 | ' ******************************************************************************************* 94 | TASK Task1 95 | ' ******************************************************************************************* 96 | 97 | ' ---------------------------------------------------------------------- 98 | ' TASK COG: I/O Pins 99 | ' ---------------------------------------------------------------------- 100 | 101 | ' ---------------------------------------------------------------------- 102 | ' TASK COG: Constants 103 | ' ---------------------------------------------------------------------- 104 | 105 | ' ---------------------------------------------------------------------- 106 | ' TASK COG: Variables (Long only) 107 | ' ---------------------------------------------------------------------- 108 | TX_BAUD VAR LONG 109 | RX_BAUD VAR LONG 110 | 111 | TX_PIN VAR LONG 112 | RX_PIN VAR LONG 113 | 114 | 115 | ' ---------------------------------------------------------------------- 116 | ' TASK COG: SUB & FUNC Definitions 117 | ' ---------------------------------------------------------------------- 118 | ' !!! The LOAD SUB Commands MUST BE BEFORE all the other SUB and FUNC Declarations 119 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB_SUBS.pbas" 120 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB_SUBS.pbas" 121 | 122 | 123 | 124 | ' ---------------------------------------------------------------------- 125 | ' Main Task Code 126 | ' ---------------------------------------------------------------------- 127 | MAIN: 128 | 129 | TX_BAUD = Terminal_Baud 130 | RX_BAUD = Terminal_Baud 131 | 132 | DELAY_MS 5000 133 | TX_BYTE CLS 134 | 135 | 136 | ' ---------------------------------------------------------------------- 137 | ' TASK COG: SUB & FUNCTION Code 138 | ' ---------------------------------------------------------------------- 139 | 140 | 141 | 142 | ' !!! The LOAD CODE Commands MUST BE AFTER all the other SUB and FUNC Declarations, i.e. just before "ENDTASK" 143 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB_CODE.pbas" 144 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB_CODE.pbas" 145 | ENDTASK 146 | ' ******************************************************************************************* 147 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Multi-Dimensional Arrays/2 Dimensional_Array V2.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' GLOBAL: Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ---------------------------------------------------------------------- 8 | ' GLOBAL: I/O Pins 9 | ' ---------------------------------------------------------------------- 10 | TX_PIN PIN 30 INPUT 11 | RX_PIN PIN 31 INPUT 12 | 13 | ' ---------------------------------------------------------------------- 14 | ' GLOBAL: Constants 15 | ' ---------------------------------------------------------------------- 16 | ' -- !!! You HAVE TO use Variables for the BAUD Rate/s 17 | Terminal_Baud CON 115200 18 | 19 | ' -- "TX_RX_Format_Lib_.pbas" Constants --------------- 20 | HOME CON 1 21 | CR CON 13 22 | CLS CON 16 23 | 24 | ' ---------------------------------------------------------------------- 25 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 26 | ' ---------------------------------------------------------------------- 27 | 28 | Hub_Array HUB WORD(15) ' (5 x 3) Single Dimension Array to hold Multi-Dimensional Array Values 29 | 30 | 31 | ' ---------------------------------------------------------------------- 32 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 33 | ' ---------------------------------------------------------------------- 34 | 35 | 36 | ' ---------------------------------------------------------------------- 37 | ' COG 0: Variables (Long only) 38 | ' ---------------------------------------------------------------------- 39 | TX_BAUD VAR LONG 40 | RX_BAUD VAR LONG 41 | 42 | 43 | Xe CON 5 ' Number of Elements in X Dimension 44 | Ye CON 3 ' Number of Elements in Y Dimension 45 | 46 | X_Loop CON (Xe - 1) ' Number of Elements Loop limit for X Dimension 47 | Y_Loop CON (Ye - 1) ' Number of Elements Loop limit for Y Dimension 48 | 49 | ' Array VAR LONG(15) ' (5 x 3) Single Dimension Array to hold Multi-Dimensional Array Values 50 | 51 | Xi VAR LONG ' Calculated X Index for the Array 52 | 53 | Idx VAR LONG ' Calculated Index for the Single Dimension Array 54 | 55 | Xc VAR LONG ' X Co-ordinate 56 | Yc VAR LONG ' Y Co-ordinate 57 | 58 | Temp VAR LONG 59 | 60 | 61 | 62 | ' ---------------------------------------------------------------------- 63 | ' COG 0: SUB & FUNC Definitions 64 | ' ---------------------------------------------------------------------- 65 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB.pbas" 66 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 67 | 68 | Calc_2_Dim_Index SUB 0 69 | Write_Array SUB 1 70 | Read_Array FUNC 0 71 | 72 | 73 | 74 | 75 | ' ---------------------------------------------------------------------- 76 | ' TASK Definitions 77 | ' ---------------------------------------------------------------------- 78 | 79 | 80 | ' ====================================================================== 81 | PROGRAM START 82 | ' ====================================================================== 83 | 84 | START: 85 | 86 | TX_BAUD = Terminal_Baud 87 | RX_BAUD = Terminal_Baud 88 | 89 | DELAY_MS 3000 90 | TX_BYTE CLS 91 | DELAY_MS 1000 92 | 93 | 94 | ' -- Clear the Array 95 | FOR Xc = 0 TO X_Loop 96 | 97 | FOR Yc = 0 TO Y_Loop 98 | 99 | GOSUB Write_Array, 0 ' Value 100 | 101 | NEXT 102 | 103 | NEXT 104 | 105 | 106 | ' -- Write to the Array 107 | FOR Xc = 0 TO X_Loop 108 | 109 | FOR Yc = 0 TO Y_Loop 110 | 111 | GOSUB Calc_2_Dim_Index 112 | 113 | TX_DEC Xc 114 | TX_BYTE " " 115 | TX_DEC Yc 116 | TX_BYTE " " 117 | TX_DEC Idx 118 | TX_BYTE CR 119 | 120 | GOSUB Write_Array, Idx ' Value 121 | 122 | NEXT 123 | 124 | NEXT 125 | 126 | 127 | TX_BYTE CR 128 | TX_BYTE CR 129 | 130 | 131 | 132 | ' -- Read from the Array 133 | FOR Xc = 0 TO X_Loop 134 | 135 | FOR Yc = 0 TO Y_Loop 136 | 137 | TX_DEC Xc 138 | TX_BYTE " " 139 | TX_DEC Yc 140 | TX_BYTE " " 141 | 142 | Temp = Read_Array 143 | 144 | TX_DEC Temp 145 | TX_BYTE CR 146 | 147 | NEXT 148 | 149 | NEXT 150 | 151 | 152 | END 153 | 154 | 155 | ' ---------------------------------------------------------------------- 156 | ' COG 0: SUB & FUNC Code 157 | ' ---------------------------------------------------------------------- 158 | 159 | ' ---------------------------------------------------------------------- 160 | SUB Calc_2_Dim_Index 161 | 162 | ' Xi = Xc * Ye 163 | ' Idx = Xi + Yc 164 | 165 | Xi = Xc * Ye 166 | Idx = Xi + Yc 167 | 168 | ENDSUB 169 | 170 | 171 | 172 | 173 | 174 | ' ---------------------------------------------------------------------- 175 | SUB Write_Array 176 | 177 | GOSUB Calc_2_Dim_Index 178 | 179 | ' Array(Idx) = __param1 180 | 181 | WRWORD Hub_Array(Idx), __param1 182 | 183 | ENDSUB 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | ' ---------------------------------------------------------------------- 192 | FUNC Read_Array 193 | 194 | GOSUB Calc_2_Dim_Index 195 | 196 | ' __param1 = Array(Idx) 197 | 198 | RDWORD Hub_Array(Idx), __param1 199 | 200 | RETURN __param1 201 | 202 | ENDFUNC 203 | 204 | 205 | 206 | -------------------------------------------------------------------------------- /src/_RANDOM.PAS: -------------------------------------------------------------------------------- 1 | Unit _RANDOM; 2 | 3 | {$MODE Delphi} 4 | 5 | // LMM Index 6 | 7 | Interface 8 | 9 | Uses GLOBAL; 10 | 11 | Procedure ProcessRandom; 12 | 13 | Implementation 14 | 15 | Procedure ProcessRandom; 16 | Begin 17 | If (g_iCmdCnt = 2) or (g_iCmdCnt = 4) Then 18 | Begin 19 | If g_apoCmdVars[2]^.eGetType = e_LongVar Then 20 | Begin 21 | If g_apoCmdVars[2]^.m_bVarIndex Then 22 | Begin 23 | If g_bLMM Then 24 | Begin 25 | OutStr(' mov __INDEX,#'+g_apoCmdVars[2]^.sGetName); 26 | OutStr(' add __INDEX,'+g_apoCmdVars[2]^.m_sIndex); 27 | OutStr(' jmp #_LMM_MOVS'); 28 | End 29 | Else 30 | Begin 31 | OutStr(' add '+g_apoCmdVars[2]^.m_sIndex+',#'+g_apoCmdVars[2]^.sGetName); 32 | OutStr(' movs $+2,'+g_apoCmdVars[2]^.m_sIndex); 33 | OutStr(' sub '+g_apoCmdVars[2]^.m_sIndex+',#'+g_apoCmdVars[2]^.sGetName); 34 | End; 35 | OutStr(' mov __temp2,0-0'); 36 | OutStr(' min __temp2,#1'); 37 | OutStr(' mov __temp1,#32'); 38 | OutStr(NewLabelStr); 39 | OutStr(' test __temp2,#%10111 WC'); 40 | OutStr(' rcr __temp2,#1'); 41 | If g_bLMM Then 42 | Begin 43 | OutStr(' djnz __temp1,#_LMM_JUMP WC'); 44 | OutStr(' long @@@'+LabelStr); 45 | End 46 | Else OutStr(' djnz __temp1,#'+LabelStr+' WC'); 47 | If g_bLMM Then 48 | Begin 49 | OutStr(' mov __INDEX,#'+g_apoCmdVars[2]^.sGetName); 50 | OutStr(' add __INDEX,'+g_apoCmdVars[2]^.m_sIndex); 51 | OutStr(' jmp #_LMM_MOVD'); 52 | End 53 | Else 54 | Begin 55 | OutStr(' add '+g_apoCmdVars[2]^.m_sIndex+',#'+g_apoCmdVars[2]^.sGetName); 56 | OutStr(' movd $+2,'+g_apoCmdVars[2]^.m_sIndex); 57 | OutStr(' sub '+g_apoCmdVars[2]^.m_sIndex+',#'+g_apoCmdVars[2]^.sGetName); 58 | End; 59 | OutStr(' mov 0-0,__temp2'); 60 | End 61 | Else 62 | Begin 63 | OutStr(' min '+g_apoCmdVars[2]^.sGetIndexName+',#1'); 64 | OutStr(' mov __temp1,#32'); 65 | OutStr(NewLabelStr); 66 | OutStr(' test '+g_apoCmdVars[2]^.sGetIndexName+',#%10111 WC'); 67 | OutStr(' rcr '+g_apoCmdVars[2]^.sGetIndexName+',#1'); 68 | If g_bLMM Then 69 | Begin 70 | OutStr(' djnz __temp1,#_LMM_JUMP WC'); 71 | OutStr(' long @@@'+LabelStr); 72 | End 73 | Else OutStr(' djnz __temp1,#'+LabelStr+' WC'); 74 | End; 75 | VP_WriteVar(2); 76 | g_bHandled:=True; 77 | End 78 | Else Error(c_iErrorInvalidParameter, 2); 79 | If g_iCmdCnt = 4 Then 80 | Begin 81 | If g_asCmdLine[3] <> ',' Then Error(c_iErrorCommaExpected, 3); 82 | If g_apoCmdVars[4]^.eGetType = e_LongVar Then 83 | Begin 84 | If g_apoCmdVars[2]^.m_bVarIndex Then 85 | Begin // [2] is var index, value in __temp2 86 | If g_apoCmdVars[4]^.m_bVarIndex Then 87 | Begin 88 | If g_bLMM Then 89 | Begin 90 | OutStr(' mov __INDEX,#'+g_apoCmdVars[4]^.sGetName); 91 | OutStr(' add __INDEX,'+g_apoCmdVars[4]^.m_sIndex); 92 | OutStr(' jmp #_LMM_MOVD'); 93 | End 94 | Else 95 | Begin 96 | OutStr(' add '+g_apoCmdVars[4]^.m_sIndex+',#'+g_apoCmdVars[4]^.sGetName); 97 | OutStr(' movd $+2,'+g_apoCmdVars[4]^.m_sIndex); 98 | OutStr(' sub '+g_apoCmdVars[4]^.m_sIndex+',#'+g_apoCmdVars[4]^.sGetName); 99 | End; 100 | OutStr(' mov 0-0,__temp2'); 101 | End 102 | Else OutStr(' mov '+g_apoCmdVars[4]^.sGetIndexName+',__temp2'); 103 | End 104 | Else 105 | Begin // [2] is not var index 106 | If g_apoCmdVars[4]^.m_bVarIndex Then 107 | Begin 108 | If g_bLMM Then 109 | Begin 110 | OutStr(' mov __INDEX,#'+g_apoCmdVars[4]^.sGetName); 111 | OutStr(' add __INDEX,'+g_apoCmdVars[4]^.m_sIndex); 112 | OutStr(' jmp #_LMM_MOVD'); 113 | End 114 | Else 115 | Begin 116 | OutStr(' add '+g_apoCmdVars[4]^.m_sIndex+',#'+g_apoCmdVars[4]^.sGetName); 117 | OutStr(' movd $+2,'+g_apoCmdVars[4]^.m_sIndex); 118 | OutStr(' sub '+g_apoCmdVars[4]^.m_sIndex+',#'+g_apoCmdVars[4]^.sGetName); 119 | End; 120 | OutStr(' mov 0-0,'+g_apoCmdVars[2]^.sGetIndexName); 121 | End 122 | Else OutStr(' mov '+g_apoCmdVars[4]^.sGetIndexName+','+g_apoCmdVars[2]^.sGetIndexName); 123 | End; 124 | End 125 | Else Error(c_iErrorInvalidParameter, 4); 126 | VP_WriteVar(4); 127 | End; // IF g_icmdCnt = 4 128 | End; 129 | End; 130 | 131 | { code from interpreter.spin 132 | "z" flag indicates a forward of backward random 133 | we only need to do forward 134 | 135 | :rnd min x,#1 '?var/var? 136 | mov y,#32 137 | mov a,#%10111 138 | if_nz ror a,#1 139 | :rndlp test x,a wc 140 | if_z rcr x,#1 141 | if_nz rcl x,#1 142 | djnz y,#:rndlp wc 'c=0 143 | 144 | 145 | Below is code for if z is set 146 | 147 | :rnd min x,#1 '?var/var? 148 | mov y,#32 149 | mov a,#%10111 150 | 151 | :rndlp test x,a wc 152 | rcr x,#1 153 | djnz y,#:rndlp wc 'c=0 154 | 155 | } 156 | 157 | End. 158 | 159 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Utilities/Libraries/UTILS_LIB_SUBS.pbas: -------------------------------------------------------------------------------- 1 | 2 | ' LOADing separate SUBS and CODE files works in both the Main Program and in Tasks 3 | 4 | 5 | Wait_PEQ SUB 2 ' Shell for WAITPEQ. Generates MASK and STATE from __param1 and __param2. Works for a Single Pin Only! 6 | Wait_PNE SUB 2 ' Shell for WAITPNE. Generates MASK and STATE from __param1 and __param2. Works for a Single Pin Only! 7 | 8 | Transpose_Bits FUNC 3 ' Transpose a Specified Number of Bits, Starting from a Specified LOW Bit Position 9 | 10 | Get_Digit FUNC 2 ' Get a specified digit from a Variable 11 | 12 | DCD_Bit FUNC 1 ' Set the Bit Number as specified by a Variable Value to "1". All the other Bits are "0". 13 | ' The LSB is Bit number 0!. 14 | ' This is the same as PBASIC "DCD" 15 | 16 | NCD_High FUNC 1 ' The same principle as PBASIC "NCD": It finds the HIGHEST BIT whichis set to "1". 17 | ' !!!! In PBASIC the LSB = Bit 1, in this Routine the LSB = Bit 0 !!!! 18 | ' If No Bit is set, $FF (255) is Returned. 19 | NCD_Low FUNC 1 ' The same principle as PBASIC "NCD", except it finds the LOWEST BIT which is set to "1". 20 | ' !!!! In PBASIC the LSB = Bit 1, in this Routine the LSB = Bit 0 !!!! 21 | ' If No Bit is set, $FF (255) is Returned. 22 | 23 | Invert_Bit FUNC 2 ' Invert the value of a Single Bit in a Variable. All other Bits are left as they are. 24 | Invert_Bits FUNC 2 ' PropBasic also has "~", but the Function in this Library optionally clears the upper bits depending 25 | ' on __param2 so the Sign Bit can also be cleared. 26 | ' The Number of Lower Bits to invert and not to clear is specified by __param2 27 | 28 | Set_Bit FUNC 2 ' Sets the specified Bit to "1". All other Bits are left as they are. 29 | Clear_Bit FUNC 2 ' Sets the specified Bit to "0". All other Bits are left as they are. 30 | Put_Bit FUNC 3 ' Sets the specified Bit to "1" or "0". All other Bits are left as they are. 31 | Copy_Bit FUNC 4 ' Copy a specified Bit from one Variable into a Specified Bit of Another Variable. 32 | Get_Bit FUNC 2 ' Get the value of a Specific Bit Number from a Variable. The value is returned in Bit 0!. 33 | 34 | Set_Nib FUNC 2 ' Sets all the Bits of a Specified Nibble to "1". All other Bits are left as they are. 35 | Clear_Nib FUNC 2 ' Sets all the Bits of a Specified Nibble to "0". All other Bits are left as they are. 36 | Put_Nib FUNC 3 ' Put the Value of Nibble 0 of a Variable (or a literal) into a another (or the same) Variable in a 37 | ' specified Nibble position 38 | Copy_Nib FUNC 4 ' Copy a specified Nibble from one Variable into a specified Nibble of Another Variable. 39 | Get_Nib FUNC 2 ' Get a Nibble from a Specified Variable in a specified Nibble position. 40 | ' The value is returned in Nibble 0!. 41 | 42 | Set_Byte FUNC 2 ' Sets all the Bits of a Specified Byte to "1". All other Bits are left as they are. 43 | Clear_Byte FUNC 2 ' Sets all the Bits of a Specified Byte to "0". All other Bits are left as they are. 44 | Put_Byte FUNC 3 ' Put the Value of Byte 0 of a Variable (or a literal) into a another (or the same) Variable in a 45 | ' specified Byte position 46 | Copy_Byte FUNC 4 ' Copy a specified Byte from one Variable into a specified Byte of Another Variable. 47 | Get_Byte FUNC 2 ' Get a Byte from a Specified Variable in a specified Byte position. The value is returned in Byte 0!. 48 | 49 | Set_Word FUNC 2 ' Sets all the Bits of a Specified Word to "1". All other Bits are left as they are. 50 | Clear_Word FUNC 2 ' Sets all the Bits of a Specified Word to "0". All other Bits are left as they are. 51 | Put_Word FUNC 3 ' Put the Value of Word 0 of a Variable (or a literal) into a another (or the same) Variable in a 52 | ' specified Word position 53 | Copy_Word FUNC 4 ' Copy a specified Word from one Variable into a specified Word of Another Variable. 54 | Get_Word FUNC 2 ' Get a Word from a Specified Variable in a specified Word position. The value is returned in Word 0!. 55 | 56 | Look_Down FUNC 2 ' The same as PBASIC LOOKDOWN 57 | Look_Up FUNC 2 ' The same as PBASIC LOOKUP 58 | 59 | DEC2BCD FUNC 1 ' Convert A Decimal Number to BCD 60 | ' BCDtoDEC FUNC 1 ' This a Function which I wrote but it uses 17 Longs MORE Program Space than BCD2DEC 61 | BCD2DEC FUNC 1 ' Convert a BCD Number to Decimal 62 | DEC2HEX FUNC 1 ' Convert a Decimal Number to HEX 63 | 64 | Piezo SUB 3 ' Used to Beep a Piezo Speaker In Single-Ended Mode. 65 | ' This Subroutine uses a FOR..NEXT Delay and Quasi Frequency. 66 | ' The code is much shorter than Freq_Out. 67 | ' For an RS Piezo Speaker the working range = 100 to 170 with 133 and 137 being the loudest 68 | 69 | PiezoX SUB 4 ' Used to Beep a Piezo Speaker In Differential Drive Mode. 70 | ' This Subroutine uses a FOR..NEXT Delay and Quasi Frequency 71 | ' The code is much shorter than Freq_OutX. 72 | ' For an RS Piezo Speaker the working range = 100 to 170 with 133 and 137 being the loudest 73 | 74 | Freq_Out SUB 3 ' Used to Output a Square Wave Signal in Single_Ended Mode. 75 | ' This Subroutine uses a Timed Delay and Actual Frequency. 76 | ' The code is much longer than Piezo. 77 | 78 | Freq_OutX SUB 4 ' Used to Output a Square Wave Signal in Differential Drive Mode. 79 | ' This Subroutine uses a Timed Delay and Actual Frequency 80 | ' The code is much longer than PiezoX. 81 | 82 | Pulse_Out SUB 3 ' Pulse a Pin: HIGH Pin, PAUSEUS X, LOW Pin, PAUSEUS Y. 83 | ' The HIGH and LOW Pauses are individually specified, giving you control of the Duty Cycle and Period 84 | 85 | Button FUNC 3 ' Sets a LONG delay if a Switch is pressed and released, or a SHORT delay if a Switch is pressed and held. 86 | ' Buton Uses COUNTERB, so if your program is already using COUNTERB, you CAN NOT use Button 87 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Loading Code and Libraries/TASK_Display_DS1302_Code.pbas: -------------------------------------------------------------------------------- 1 | ' ' ******************************************************************************************* 2 | ' TASK Display_DS1302 3 | ' ' ******************************************************************************************* 4 | 5 | ' ********************************************************* 6 | ' 7 | ' This is an example of how to "LOAD" the Code for a Task. 8 | ' The "TASK xxx" and "ENDTASK" declarations must be in the main program. 9 | ' This Code gets loaded by "Example_Task_LOAD_Main_Program.pbas" 10 | ' 11 | ' ********************************************************* 12 | 13 | ' ---------------------------------------------------------------------- 14 | ' TASK COG: I/O Pins 15 | ' ---------------------------------------------------------------------- 16 | 17 | ' ---------------------------------------------------------------------- 18 | ' TASK COG: Constants 19 | ' ---------------------------------------------------------------------- 20 | 21 | 22 | ' ---------------------------------------------------------------------- 23 | ' TASK COG: Variables (Long only) 24 | ' ---------------------------------------------------------------------- 25 | TX_BAUD VAR LONG 26 | 27 | Register_Address VAR LONG 28 | 29 | 30 | ' NOTE: The Time Variables MUST BE IN THIS ORDER FOR THE WRITE AND READ LOOPS TO WORK!!!!!! 31 | seconds VAR Long 32 | minutes VAR Long 33 | hours VAR Long 34 | date VAR Long 35 | month VAR Long 36 | day VAR Long 37 | year VAR Long 38 | 39 | Index VAR Long 40 | 41 | temp_hours VAR Long 42 | 43 | 44 | ' ---------------------------------------------------------------------- 45 | ' TASK COG: SUB & FUNC Definitions 46 | ' ---------------------------------------------------------------------- 47 | ' !!! The LOAD SUB Commands for Libraries MUST BE BEFORE your own SUB and FUNC Declarations 48 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB_SUBS.pbas" 49 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB_SUBS.pbas" 50 | 51 | 52 | Shift_Out SUB 1 53 | Shift_In FUNC 0 54 | Read_RAM FUNC 0 55 | 56 | Read_Time SUB 0 57 | Show_Time SUB 0 58 | 59 | 60 | 61 | ' ---------------------------------------------------------------------- 62 | ' Main Task Code 63 | ' ---------------------------------------------------------------------- 64 | MAIN: 65 | 66 | TX_BAUD = Terminal_Baud 67 | 68 | DELAY_MS 5000 69 | TX_BYTE CLS 70 | 71 | HIGH CS1302 ' Select DS1302 72 | 73 | Shift_Out CWPr ' Initialize DS1302 74 | 75 | Shift_Out WPr0 ' Clear Write Protect 76 | 77 | LOW CS1302 ' Deselect DS1302 78 | 79 | 80 | DO 81 | 82 | Read_Time 83 | 84 | Show_Time 85 | 86 | DELAY_MS 200 87 | 88 | LOOP 89 | 90 | 91 | ' ---------------------------------------------------------------------- 92 | ' TASK COG: SUB & FUNCTION Code 93 | ' ---------------------------------------------------------------------- 94 | 95 | ' ---------------------------------------------------------------------- 96 | SUB Shift_Out 97 | SHIFTOUT DataIO, Clock, LSBFIRST, __param1\8 98 | ENDSUB 99 | 100 | 101 | ' ---------------------------------------------------------------------- 102 | FUNC Shift_In 103 | SHIFTIN DataIO, Clock, LSBPRE, __param1\8 104 | __param1 = __param1 >> 16 105 | RETURN __param1 106 | ENDFUNC 107 | 108 | 109 | 110 | 111 | ' ---------------------------------------------------------------------- 112 | FUNC Read_RAM 113 | 114 | __param2 = Register_Address << 1 115 | __param2 = __param2 OR RdRam 116 | 117 | HIGH CS1302 118 | Shift_Out __param2 119 | __param1 = Shift_In 120 | LOW CS1302 121 | RETURN __param1 122 | ENDFUNC 123 | 124 | 125 | 126 | ' ---------------------------------------------------------------------- 127 | SUB Read_Time 128 | 129 | TX_BYTE HOME 130 | 131 | HIGH CS1302 ' Select DS1302 132 | 133 | SHIFT_OUT RdBurst 134 | 135 | FOR Index = 0 to 6 136 | seconds(Index) = Shift_In 137 | NEXT 138 | 139 | LOW CS1302 140 | 141 | temp_hours = hours 142 | 143 | __param1 = hours AND %1000_0000 144 | IF __param1 = %1000_0000 THEN ' 12-Hour Mode is set (Bit7) 145 | hours = hours AND %0101_1111 ' Clear Bit5 and Bit7 146 | ELSE 147 | hours = hours AND %0111_1111 ' Clear only Bit7 because Bit5 is the "20"s digit for 24-hour mode 148 | ENDIF 149 | 150 | ENDSUB 151 | 152 | 153 | 154 | ' ---------------------------------------------------------------------- 155 | SUB Show_Time 156 | 157 | TX_BYTE HOME 158 | TX_BYTE LF 159 | 160 | TX_STR "Day " 161 | 162 | TX_HEX day, 2 163 | 164 | TX_BYTE " " 165 | 166 | ' -- Get the Weekday Abbreviation from the DS1302 Static RAM and display 167 | Register_Address = day - 1 168 | Register_Address = Register_Address * 3 169 | 170 | __param4 = Register_Address + 2 171 | 172 | FOR Register_Address = Register_Address to __param4 173 | day = Read_RAM 174 | TX_BYTE day 175 | NEXT 176 | 177 | ' -- Display the Date and Time 178 | TX_BYTE " " 179 | 180 | TX_HEX date, 2 181 | 182 | TX_BYTE "/" 183 | 184 | TX_HEX month, 2 185 | 186 | TX_STR "/20" 187 | 188 | TX_HEX year, 2 189 | 190 | TX_STR " " 191 | 192 | TX_HEX hours, 2 193 | 194 | TX_BYTE ":" 195 | 196 | TX_HEX minutes, 2 197 | 198 | TX_BYTE ":" 199 | 200 | TX_HEX seconds, 2 201 | 202 | __param1 = temp_hours AND %1000_0000 203 | IF __param1 = %1000_0000 THEN ' 12-Hour Mode is set (Bit 7) 204 | __param1 = temp_hours AND %0010_0000 ' Check if Bit5 is set = PM 205 | IF __param1 = %0010_0000 THEN 206 | TX_STR " PM" 207 | ELSE 208 | TX_STR " AM" 209 | ENDIF 210 | ENDIF 211 | 212 | TX_BYTE CLREOL 213 | 214 | ENDSUB 215 | 216 | 217 | ' !!! The LOAD CODE Commands for Libraries MUST BE AFTER your own SUB and FUNC Declarations, i.e. just before "ENDTASK" 218 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB_CODE.pbas" 219 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB_CODE.pbas" 220 | 221 | ' ENDTASK 222 | ' ' ******************************************************************************************* 223 | 224 | 225 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Multi-Dimensional Arrays/3 Dimensional_Array V2.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' GLOBAL: Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ---------------------------------------------------------------------- 8 | ' GLOBAL: I/O Pins 9 | ' ---------------------------------------------------------------------- 10 | TX_PIN PIN 30 INPUT 11 | RX_PIN PIN 31 INPUT 12 | 13 | ' ---------------------------------------------------------------------- 14 | ' GLOBAL: Constants 15 | ' ---------------------------------------------------------------------- 16 | ' -- !!! You HAVE TO use Variables for the BAUD Rate/s 17 | Terminal_Baud CON 115200 18 | 19 | ' -- "TX_RX_Format_Lib_.pbas" Constants --------------- 20 | HOME CON 1 21 | CR CON 13 22 | CLS CON 16 23 | 24 | ' ---------------------------------------------------------------------- 25 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 26 | ' ---------------------------------------------------------------------- 27 | 28 | Hub_Array HUB WORD(24) ' (2 x 3 x 4) Single Dimension Array to hold Multi-Dimensional Array Values 29 | 30 | 31 | ' ---------------------------------------------------------------------- 32 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 33 | ' ---------------------------------------------------------------------- 34 | 35 | 36 | ' ---------------------------------------------------------------------- 37 | ' COG 0: Variables (Long only) 38 | ' ---------------------------------------------------------------------- 39 | TX_BAUD VAR LONG 40 | RX_BAUD VAR LONG 41 | 42 | 43 | Xe CON 2 ' Number of Elements in X Dimension 44 | Ye CON 3 ' Number of Elements in Y Dimension 45 | Ze CON 4 ' Number of Elements in Z Dimension 46 | 47 | X_Loop CON (Xe - 1) ' Number of Elements Loop limit for X Dimension 48 | Y_Loop CON (Ye - 1) ' Number of Elements Loop limit for Y Dimension 49 | Z_Loop CON (Ze - 1) ' Number of Elements Loop limit for Z Dimension 50 | 51 | ' Array VAR LONG(24) ' (2 x 3 x 4) Single Dimension Array to hold Multi-Dimensional Array Values 52 | 53 | Xi VAR LONG ' Calculated X Index for the Array 54 | Yi VAR LONG ' Calculated Y Index for the Array 55 | 56 | Idx VAR LONG ' Calculated Index for the Single Dimension Array 57 | 58 | Xc VAR LONG ' X Co-ordinate 59 | Yc VAR LONG ' Y Co-ordinate 60 | Zc VAR LONG ' Z Co-ordinate 61 | 62 | Temp VAR LONG 63 | 64 | 65 | 66 | ' ---------------------------------------------------------------------- 67 | ' COG 0: SUB & FUNC Definitions 68 | ' ---------------------------------------------------------------------- 69 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB.pbas" 70 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 71 | 72 | Calc_3_Dim_Index SUB 0 73 | Write_Array SUB 1 74 | Read_Array FUNC 0 75 | 76 | 77 | 78 | 79 | ' ---------------------------------------------------------------------- 80 | ' TASK Definitions 81 | ' ---------------------------------------------------------------------- 82 | 83 | 84 | ' ====================================================================== 85 | PROGRAM START 86 | ' ====================================================================== 87 | 88 | START: 89 | 90 | TX_BAUD = Terminal_Baud 91 | RX_BAUD = Terminal_Baud 92 | 93 | DELAY_MS 3000 94 | TX_BYTE CLS 95 | DELAY_MS 1000 96 | 97 | 98 | ' -- Clear the Array 99 | FOR Xc = 0 TO X_Loop 100 | 101 | FOR Yc = 0 TO Y_Loop 102 | 103 | FOR Zc = 0 TO Z_Loop 104 | 105 | GOSUB Write_Array, 0 ' Value 106 | 107 | NEXT 108 | 109 | NEXT 110 | 111 | NEXT 112 | 113 | 114 | 115 | ' -- Write to the Array 116 | FOR Xc = 0 TO X_Loop 117 | 118 | FOR Yc = 0 TO Y_Loop 119 | 120 | FOR Zc = 0 TO Z_Loop 121 | 122 | GOSUB Calc_3_Dim_Index 123 | 124 | TX_DEC Xc 125 | TX_BYTE " " 126 | TX_DEC Yc 127 | TX_BYTE " " 128 | TX_DEC Zc 129 | TX_BYTE " " 130 | TX_DEC Idx 131 | TX_BYTE CR 132 | 133 | GOSUB Write_Array, Idx ' Value 134 | 135 | NEXT 136 | 137 | NEXT 138 | 139 | NEXT 140 | 141 | 142 | TX_BYTE CR 143 | TX_BYTE CR 144 | 145 | 146 | 147 | ' -- Read from the Array 148 | FOR Xc = 0 TO X_Loop 149 | 150 | FOR Yc = 0 TO Y_Loop 151 | 152 | FOR Zc = 0 TO Z_Loop 153 | 154 | TX_DEC Xc 155 | TX_BYTE " " 156 | TX_DEC Yc 157 | TX_BYTE " " 158 | TX_DEC Zc 159 | TX_BYTE " " 160 | 161 | Temp = Read_Array 162 | 163 | TX_DEC Temp 164 | TX_BYTE CR 165 | 166 | NEXT 167 | 168 | NEXT 169 | 170 | NEXT 171 | 172 | 173 | END 174 | 175 | 176 | ' ---------------------------------------------------------------------- 177 | ' COG 0: SUB & FUNC Code 178 | ' ---------------------------------------------------------------------- 179 | 180 | ' ---------------------------------------------------------------------- 181 | SUB Calc_3_Dim_Index 182 | 183 | ' Xi = Xc * Ye 184 | ' Idx = Xi + Yc 185 | 186 | Xi = Xc * Ye 187 | Xi = Xi * Ze 188 | 189 | Yi = Yc * Ze 190 | 191 | Idx = Xi + Yi 192 | Idx = Idx + Zc 193 | 194 | ENDSUB 195 | 196 | 197 | 198 | 199 | ' ---------------------------------------------------------------------- 200 | SUB Write_Array 201 | 202 | GOSUB Calc_3_Dim_Index 203 | 204 | ' Array(Idx) = __param1 205 | 206 | WRWORD Hub_Array(Idx), __param1 207 | 208 | ENDSUB 209 | 210 | 211 | 212 | ' ---------------------------------------------------------------------- 213 | FUNC Read_Array 214 | 215 | GOSUB Calc_3_Dim_Index 216 | 217 | ' __param1 = Array(Idx) 218 | 219 | RDWORD Hub_Array(Idx), __param1 220 | 221 | RETURN __param1 222 | 223 | ENDFUNC 224 | 225 | 226 | 227 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Utilities/Sample Code/LOOKDOWN_LOOKUP_Test.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ---------------------------------------------------------------------- 8 | ' GLOBAL: I/O Pins 9 | ' ---------------------------------------------------------------------- 10 | TX_PIN PIN 30 INPUT 11 | 12 | 13 | ' ---------------------------------------------------------------------- 14 | ' GLOBAL: Constants 15 | ' ---------------------------------------------------------------------- 16 | Terminal_Baud CON 115200 17 | 18 | C0 CON "A" 19 | C1 CON "B" 20 | C2 CON "C" 21 | C3 CON "D" 22 | C4 CON "E" 23 | 24 | 25 | N0 CON 10 26 | N1 CON 11 27 | N2 CON 12 28 | N3 CON 13 29 | N4 CON 14 30 | 31 | ' ---------------------------------------------------------------------- 32 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 33 | ' ---------------------------------------------------------------------- 34 | 35 | 36 | ' ---------------------------------------------------------------------- 37 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 38 | ' ---------------------------------------------------------------------- 39 | 40 | Char0 DATA "[ABCDE]" 41 | 42 | Char1 DATA "[", C0, C1, C2, C3, C4, "]" 43 | 44 | Char2 DATA "[", 20, 30, 40, 50, 60 "]" 45 | 46 | Char3 DATA "[", N0, N1, N2, N3, N4, "]" 47 | 48 | txt0 DATA "LOOKDOWN Char : ", 0 49 | 50 | txt1 DATA "LOOKDOWN Index : ", 0 51 | 52 | txt2 DATA "LOOKUP Index : ", 0 53 | 54 | txt3 DATA "LOOKUP Char : ", 0 55 | 56 | 57 | ' ---------------------------------------------------------------------- 58 | ' COG 0: Variables (Long only) 59 | ' ---------------------------------------------------------------------- 60 | TX_BAUD VAR LONG 61 | 62 | Key VAR Long 63 | 64 | Temp VAR LONG 65 | 66 | ' ---------------------------------------------------------------------- 67 | ' COG 0: SUB & FUNC Definitions 68 | ' ---------------------------------------------------------------------- 69 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 70 | LOAD "D:\Propeller\Propeller Programs\Libraries\UTILS_LIB.pbas" 71 | 72 | 73 | ' ---------------------------------------------------------------------- 74 | ' TASK Definitions 75 | ' ---------------------------------------------------------------------- 76 | 77 | 78 | ' ====================================================================== 79 | PROGRAM START 80 | ' ====================================================================== 81 | 82 | 83 | START: 84 | 85 | TX_BAUD = Terminal_Baud 86 | 87 | PAUSE 5000 ' Allow time to open Serial Terminal 88 | 89 | SEROUT TX_PIN, T115200, 16 90 | 91 | Main: 92 | 93 | '*************************************************************************** 94 | ' !!! Remember that the Look_Down and Look_Up Indexing starts with Zero !!! 95 | '*************************************************************************** 96 | 97 | 98 | ' -- Test with Characters --------------------------------------------------------------------------- 99 | 100 | TX_STR ">> Testing Characters --------------------------------------" 101 | TX_BYTE 13 102 | TX_BYTE 13 103 | 104 | Key = "E" ' Find the Index of this Character 105 | 106 | TX_STR txt0 107 | TX_BYTE Key 108 | TX_BYTE 13 109 | 110 | Temp = Look_Down Char0, Key ' This syntax also works: Temp = Look_Down Char0, "E" 111 | 112 | TX_STR txt1 113 | TX_DEC Temp 114 | TX_BYTE 13 115 | TX_BYTE 13 116 | 117 | Key = 2 ' Find the Character of this Index 118 | 119 | TX_STR txt2 120 | TX_DEC Key 121 | TX_BYTE 13 122 | 123 | Temp = Look_Up Char0, Key ' This syntax also works: Temp = Look_Up Char0, 2 124 | 125 | TX_STR txt3 126 | TX_BYTE Temp 127 | TX_BYTE 13 128 | TX_BYTE 13 129 | 130 | TX_STR "--------------------------------------" 131 | TX_BYTE 13 132 | TX_BYTE 13 133 | 134 | ' Now test with Character Constants ---------------------------------------- 135 | 136 | Key = "E" ' Find the Index of this Character 137 | 138 | TX_STR txt0 139 | TX_BYTE Key 140 | TX_BYTE 13 141 | 142 | Temp = Look_Down Char1, Key 143 | 144 | TX_STR txt1 145 | TX_DEC Temp 146 | TX_BYTE 13 147 | TX_BYTE 13 148 | 149 | Key = 2 ' Find the Character of this Index 150 | 151 | TX_STR txt2 152 | TX_DEC Key 153 | TX_BYTE 13 154 | 155 | Temp = Look_Up Char1, Key 156 | 157 | TX_STR txt3 158 | TX_BYTE Temp 159 | TX_BYTE 13 160 | TX_BYTE 13 161 | 162 | 163 | 164 | ' -- Test with Numbers --------------------------------------------------------------------------- 165 | 166 | TX_STR ">> Testing Numbers --------------------------------------" 167 | TX_BYTE 13 168 | TX_BYTE 13 169 | 170 | Key = 30 ' Find the Index of this Number 171 | 172 | TX_STR txt0 173 | TX_DEC Key 174 | TX_BYTE 13 175 | 176 | Temp = Look_Down Char2, Key ' This syntax also works: Temp = Look_Down Char2, 30 177 | 178 | TX_STR txt1 179 | TX_DEC Temp 180 | TX_BYTE 13 181 | TX_BYTE 13 182 | 183 | Key = 2 ' Find the Character of this Index 184 | 185 | TX_STR txt2 186 | TX_DEC Key 187 | TX_BYTE 13 188 | 189 | Temp = Look_Up Char2, Key ' This syntax also works: Temp = Look_Up Char2, 2 190 | 191 | TX_STR txt3 192 | TX_DEC Temp 193 | TX_BYTE 13 194 | TX_BYTE 13 195 | 196 | TX_STR "--------------------------------------" 197 | TX_BYTE 13 198 | TX_BYTE 13 199 | 200 | ' Now test with Number Constants ---------------------------------------- 201 | 202 | Key = 12 ' Find the Index of this Character 203 | 204 | TX_STR txt0 205 | TX_DEC Key 206 | TX_BYTE 13 207 | 208 | Temp = Look_Down Char3, Key 209 | 210 | TX_STR txt1 211 | TX_DEC Temp 212 | TX_BYTE 13 213 | TX_BYTE 13 214 | 215 | Key = 3 ' Find the Character of this Index 216 | 217 | TX_STR txt2 218 | TX_DEC Key 219 | TX_BYTE 13 220 | 221 | Temp = Look_Up Char3, Key 222 | 223 | TX_STR txt3 224 | TX_DEC Temp 225 | 226 | END 227 | 228 | 229 | ' ---------------------------------------------------------------------- 230 | ' COG 0: SUB & FUNC Code 231 | ' ---------------------------------------------------------------------- 232 | 233 | -------------------------------------------------------------------------------- /src/DEVICES.PAS: -------------------------------------------------------------------------------- 1 | Unit DEVICES; 2 | 3 | {$MODE Delphi} 4 | 5 | INTERFACE 6 | 7 | Procedure DeviceP8X32A; 8 | Procedure DeviceP2; 9 | 10 | IMPLEMENTATION 11 | 12 | Uses GLOBAL; 13 | 14 | Procedure DeviceP8X32A; 15 | Var 16 | sTemp: String; 17 | poVar: PVarObj; 18 | Begin 19 | sTemp:=g_sOrigLine; 20 | If Pos('''', sTemp) > 0 Then sTemp:=Copy(sTemp, 1, Pos('''', sTemp)-1); 21 | With g_oDevice Do 22 | Begin 23 | m_oVars.Init; 24 | m_eType:=e_P8X32A; 25 | AddDirective('P8X32A'); 26 | WriteLn(g_tfSrc); 27 | 28 | // The following are already included in the Propeller IDE 29 | poVar:=pAddLongVar('dira', False, '0'); 30 | poVar^.m_bPermanent:=True; 31 | poVar:=pAddLongVar('ina', False, '0'); 32 | poVar^.m_bPermanent:=True; 33 | poVar:=pAddLongVar('outa', False, '0'); 34 | poVar^.m_bPermanent:=True; 35 | poVar:=pAddLongVar('cnt', False, '0'); 36 | poVar^.m_bPermanent:=True; 37 | poVar:=pAddLongVar('ctra', False, '0'); 38 | poVar^.m_bPermanent:=True; 39 | poVar:=pAddLongVar('ctrb', False, '0'); 40 | poVar^.m_bPermanent:=True; 41 | poVar:=pAddLongVar('frqa', False, '0'); 42 | poVar^.m_bPermanent:=True; 43 | poVar:=pAddLongVar('frqb', False, '0'); 44 | poVar^.m_bPermanent:=True; 45 | 46 | poVar:=pAddLongVar('phsa', False, '0'); 47 | poVar^.m_bShadowReg:=True; 48 | poVar^.m_bPermanent:=True; 49 | 50 | poVar:=pAddLongVar('phsb', False, '0'); 51 | poVar^.m_bShadowReg:=True; 52 | poVar^.m_bPermanent:=True; 53 | 54 | poVar:=pAddLongVar('vcfg', False, '0'); 55 | poVar^.m_bPermanent:=True; 56 | poVar:=pAddLongVar('vscl', False, '0'); 57 | poVar^.m_bPermanent:=True; 58 | poVar:=pAddLongVar('par', False, '0'); 59 | poVar^.m_bPermanent:=True; 60 | 61 | poVar:=pAddLongVar('__RAM', False, '0'); 62 | poVar^.m_bPermanent:=True; 63 | 64 | poVar:=pAddHubByte('__STRING', 0, 0, 0); 65 | poVar^.m_bHubAbs:=True; 66 | poVar^.m_bPermanent:=True; 67 | 68 | // pAddHubByte('__HUBBYTE', 0, 0, 0); 69 | // pAddHubWord('__HUBWORD', 0, 0, 0); 70 | // pAddHubLong('__HUBLONG', 0, 0, 0); 71 | 72 | poVar:=pAddLongVar('__temp1', False, '0'); 73 | poVar^.m_bPermanent:=True; 74 | poVar:=pAddLongVar('__temp2', False, '0'); 75 | poVar^.m_bPermanent:=True; 76 | poVar:=pAddLongVar('__temp3', False, '0'); 77 | poVar^.m_bPermanent:=True; 78 | poVar:=pAddLongVar('__temp4', False, '0'); 79 | poVar^.m_bPermanent:=True; 80 | poVar:=pAddLongVar('__remainder', False, '0'); 81 | poVar^.m_sAlias:='__temp4'; 82 | poVar^.m_bPermanent:=True; 83 | poVar:=pAddLongVar('__temp5', False, '0'); 84 | poVar^.m_bPermanent:=True; 85 | poVar:=pAddLongVar('__param1', False, '0'); 86 | poVar^.m_bPermanent:=True; 87 | poVar:=pAddLongVar('__param2', False, '0'); 88 | poVar^.m_bPermanent:=True; 89 | poVar:=pAddLongVar('__param3', False, '0'); 90 | poVar^.m_bPermanent:=True; 91 | poVar:=pAddLongVar('__param4', False, '0'); 92 | poVar^.m_bPermanent:=True; 93 | poVar:=pAddLongVar('__paramcnt', False, '0'); 94 | poVar^.m_bPermanent:=True; 95 | 96 | poVar:=pAddHubLong('clkfreq', 0, 1, 0); 97 | poVar^.m_bHubAbs:=True; 98 | poVar^.m_bPermanent:=True; 99 | 100 | // PropBASIC constants 101 | poVar:=pAddShortConst('LSBFIRST', 0, '0'); 102 | poVar^.m_bPermanent:=True; 103 | poVar:=pAddShortConst('MSBFIRST', 1, '1'); 104 | poVar^.m_bPermanent:=True; 105 | poVar:=pAddShortConst('MSBPRE', 0, '0'); 106 | poVar^.m_bPermanent:=True; 107 | poVar:=pAddShortConst('LSBPRE', 1, '1'); 108 | poVar^.m_bPermanent:=True; 109 | poVar:=pAddShortConst('MSBPOST', 2, '2'); 110 | poVar^.m_bPermanent:=True; 111 | poVar:=pAddShortConst('LSBPOST', 3, '3'); 112 | poVar^.m_bPermanent:=True; 113 | End; { With oDevice } 114 | WriteLn(g_tfSrc); 115 | g_bIsP1:=True; 116 | g_bIsP2:=False; 117 | g_iMaxPin:=31; 118 | g_bHandled:=True; 119 | End; 120 | 121 | Procedure DeviceP2; 122 | Var 123 | sTemp: String; 124 | poVar: PVarObj; 125 | Begin 126 | sTemp:=g_sOrigLine; 127 | If Pos('''', sTemp) > 0 Then sTemp:=Copy(sTemp, 1, Pos('''', sTemp)-1); 128 | With g_oDevice Do 129 | Begin 130 | m_oVars.Init; 131 | m_eType:=e_P2; 132 | AddDirective('P2'); 133 | WriteLn(g_tfSrc); 134 | 135 | // The following are already included in the Propeller IDE 136 | pAddLongVar('dira', False, '0'); 137 | pAddLongVar('ina', False, '0'); 138 | pAddLongVar('outa', False, '0'); 139 | pAddLongVar('dirb', False, '0'); 140 | pAddLongVar('inb', False, '0'); 141 | pAddLongVar('outb', False, '0'); 142 | pAddLongVar('cnt', False, '0'); 143 | pAddLongVar('ctra', False, '0'); 144 | pAddLongVar('ctrb', False, '0'); 145 | pAddLongVar('frqa', False, '0'); 146 | pAddLongVar('frqb', False, '0'); 147 | 148 | poVar:=pAddLongVar('phsa', False, '0'); 149 | poVar^.m_bShadowReg:=True; 150 | 151 | poVar:=pAddLongVar('phsb', False, '0'); 152 | poVar^.m_bShadowReg:=True; 153 | 154 | pAddLongVar('vcfg', False, '0'); 155 | pAddLongVar('vscl', False, '0'); 156 | pAddLongVar('par', False, '0'); 157 | 158 | pAddLongVar('__RAM', False, '0'); 159 | 160 | poVar:=pAddHubByte('__STRING', 0, 0, 0); 161 | poVar^.m_bHubAbs:=True; 162 | 163 | // pAddHubByte('__HUBBYTE', 0, 0, 0); 164 | // pAddHubWord('__HUBWORD', 0, 0, 0); 165 | // pAddHubLong('__HUBLONG', 0, 0, 0); 166 | 167 | 168 | pAddLongVar('__temp1', False, '0'); 169 | poVar:=pAddLongVar('__remainder', False, '0'); 170 | poVar^.m_sAlias:='__temp1'; 171 | pAddLongVar('__temp2', False, '0'); 172 | pAddLongVar('__temp3', False, '0'); 173 | pAddLongVar('__temp4', False, '0'); 174 | pAddLongVar('__temp5', False, '0'); 175 | pAddLongVar('__param1', False, '0'); 176 | pAddLongVar('__param2', False, '0'); 177 | pAddLongVar('__param3', False, '0'); 178 | pAddLongVar('__param4', False, '0'); 179 | pAddLongVar('__paramcnt', False, '0'); 180 | poVar:=pAddHubLong('clkfreq', 0, 1, 0); 181 | poVar^.m_bHubAbs:=True; 182 | 183 | // PropBASIC constants 184 | pAddShortConst('LSBFIRST', 0, '0'); 185 | pAddShortConst('MSBFIRST', 1, '1'); 186 | pAddShortConst('MSBPRE', 0, '0'); 187 | pAddShortConst('LSBPRE', 1, '1'); 188 | pAddShortConst('MSBPOST', 2, '2'); 189 | pAddShortConst('LSBPOST', 3, '3'); 190 | End; { With oDevice } 191 | WriteLn(g_tfSrc); 192 | g_bIsP1:=False; 193 | g_bIsP2:=True; 194 | g_iMaxpin:=127; 195 | g_bHandled:=True; 196 | End; 197 | 198 | 199 | End. 200 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/LCD Directly Connected/Sample Code/LCD_Test_STR_NUM_LIB.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' GLOBAL: Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' !!!!! You MUST use (at least 2 ms) DELAY_MS 2 after every PULSOUT LCD_E, 3 8 | 9 | 10 | 11 | ' ---------------------------------------------------------------------- 12 | ' GLOBAL: I/O Pins 13 | ' ---------------------------------------------------------------------- 14 | 15 | LCD_RS PIN 0 16 | ' LCD_RW PIN X ' RDBYTE/Write - Connected directly to Ground 17 | LCD_E PIN 1 18 | 19 | LCD_DB4 PIN 2 20 | LCD_DB5 PIN 3 21 | LCD_DB6 PIN 4 22 | LCD_DB7 PIN 5 23 | 24 | LCD_Bus PIN 5.. 2 OUTPUT ' !!! The Pins must be in MSB to LSB Order. 4-bit LCD data bus PIN Group 25 | 26 | ' ---------------------------------------------------------------------- 27 | ' GLOBAL: Constants 28 | ' ---------------------------------------------------------------------- 29 | 30 | 31 | 32 | ' -----[ LCD Constants ]------------------------------------------------------- 33 | LcdCls CON $01 ' clear the LCD 34 | ' LcdHome CON $02 ' move cursor home 35 | ' LcdCrsrL CON $10 ' move cursor left 36 | ' LcdCrsrR CON $14 ' move cursor right 37 | ' LcdDispL CON $18 ' shift LCD_Datas left 38 | ' LcdDispR CON $1C ' shift LCD_Datas right 39 | LcdCGRam CON $40 ' Character Generator RAM 40 | LcdLine1 CON $80 ' DDRAM address of line 1 (DB7 = 1) 41 | LcdLine2 CON $C0 ' DDRAM address of line 2 42 | LcdLine3 CON $94 ' DDRAM address of line 3 43 | LcdLine4 CON $D4 ' DDRAM address of line 4 44 | 45 | 46 | ' ---------------------------------------------------------------------- 47 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 48 | ' ---------------------------------------------------------------------- 49 | 50 | 51 | ' ---------------------------------------------------------------------- 52 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 53 | ' ---------------------------------------------------------------------- 54 | 55 | Char0 DATA "Testing DATA Line 01", 0 56 | Char1 DATA "Testing DATA Line 02", "@" 57 | 58 | 59 | ' ---------------------------------------------------------------------- 60 | ' COG 0: Variables (Long only) 61 | ' ---------------------------------------------------------------------- 62 | ' ************************************************************************************************************** 63 | ' NOTE: The Main Program MUST contain this Variable because it is used by this Library 64 | 65 | LCD_Data VAR LONG ' Data sent by Main Program to LCD. 66 | 67 | ' ************************************************************************************************************** 68 | 69 | ' ---------------------------------------------------------------------- 70 | ' COG 0: SUB & FUNC Definitions 71 | ' ---------------------------------------------------------------------- 72 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB.pbas" 73 | LOAD "D:\Propeller\Propeller Programs\Libraries\LCD_DIRECT_LIB.pbas" 74 | 75 | 76 | ' ---------------------------------------------------------------------- 77 | ' TASK Definitions 78 | ' ---------------------------------------------------------------------- 79 | 80 | 81 | ' ====================================================================== 82 | PROGRAM START 83 | ' ====================================================================== 84 | 85 | START: 86 | 87 | OUTPUT LCD_Bus 88 | 89 | 90 | ' -- Initialise LCD in 4-BIT Mode ----------------------------------------------------- 91 | LOW LCD_E ' Set LCD Enable to Initial LOW State 92 | LOW LCD_RS ' NB!!! Set LCD RS to Command mode 93 | DELAY_MS 100 ' let the LCD settle 94 | 95 | LCD_Bus = %0011 ' 8-bit mode 96 | PULSOUT LCD_E, 1 97 | DELAY_MS 5 98 | PULSOUT LCD_E, 1 99 | DELAY_MS 2 100 | PULSOUT LCD_E, 1 101 | DELAY_MS 2 102 | LCD_Bus = %0010 ' 4-Bit Mode, 1-line, 5x7 font %00100000 103 | PULSOUT LCD_E, 1 104 | DELAY_MS 2 105 | GOSUB LCD_CMD, %00001100 ' on, no crsr, no Blink 106 | GOSUB LCD_CMD, %00000110 ' Set Entry Mode 107 | 108 | GOSUB LCD_CMD, LcdCls 109 | 110 | 111 | ' DELAY_MS 3000 112 | 113 | ' -----[ Program Code ]---------------------------------------------------- 114 | 115 | Main: 116 | ' -- Write Message ------------------------------------------- 117 | GOSUB LCD_CMD, LcdLine1 118 | GOSUB LCD_STR, Char0 119 | 120 | ' -- Write Message ------------------------------------------- 121 | GOSUB LCD_CMD, LcdLine2 122 | GOSUB LCD_STR, Char1 123 | 124 | DELAY_MS 3000 125 | GOSUB LCD_CMD, LcdCls 126 | 127 | 128 | ' Write the number without Leading Zeroes or Spaces 129 | ' Digit_Count must be at least the same as the number of characters of the number else they will be truncated, but it doesn't matter if 130 | ' Digit_Count is bigger than the number of characters 131 | GOSUB LCD_CMD, LcdLine1 132 | GOSUB LCD_STR, "No Leading Spaces " 133 | GOSUB LCD_CMD, LcdLine2 134 | GOSUB LCD_STR, "No Leading Zeroes " 135 | 136 | GOSUB LCD_CMD, LcdLine3 137 | GOSUB LCD_DEC, 123010, 10 ' GOSUB LCD_DEC, Number, How many Digits to write 138 | 139 | DELAY_MS 5000 140 | GOSUB LCD_CMD, LcdCls 141 | 142 | 143 | ' Write the number with Leading Zeroes 144 | ' Digit_Count must be at least the same as the number of characters of the number else they will be truncated 145 | GOSUB LCD_CMD, LcdLine1 146 | GOSUB LCD_STR, "Leading Zeroes " 147 | 148 | GOSUB LCD_CMD, LcdLine2 149 | GOSUB LCD_DECLZ, 123010, 10 ' GOSUB LCD_DEC, Number, How many Digits to write 150 | 151 | DELAY_MS 5000 152 | GOSUB LCD_CMD, LcdCls 153 | 154 | 155 | ' Write the number with Leading Spaces 156 | ' Digit_Count must be at least the same as the number of characters of the number else they will be truncated 157 | GOSUB LCD_CMD, LcdLine1 158 | GOSUB LCD_STR, "Leading Spaces " 159 | 160 | GOSUB LCD_CMD, LcdLine2 161 | GOSUB LCD_DECLS, 123010, 10 ' GOSUB LCD_DEC, Number, How many Digits to write 162 | 163 | DELAY_MS 5000 164 | DELAY_MS 5000 165 | GOSUB LCD_CMD, LcdCls 166 | 167 | GOTO Main 168 | 169 | 170 | 171 | END 172 | 173 | 174 | ' ---------------------------------------------------------------------- 175 | ' COG 0: SUB & FUNC Code 176 | ' ---------------------------------------------------------------------- 177 | -------------------------------------------------------------------------------- /example/Community Contributed Examples/Andre Nieuwoudt/Multi-Dimensional Arrays/4 Dimensional_Array V2.pbas: -------------------------------------------------------------------------------- 1 | ' ---------------------------------------------------------------------- 2 | ' GLOBAL: Device Settings 3 | ' ---------------------------------------------------------------------- 4 | DEVICE P8X32A, XTAL1, PLL16X 5 | XIN 5_000_000 6 | 7 | ' ---------------------------------------------------------------------- 8 | ' GLOBAL: I/O Pins 9 | ' ---------------------------------------------------------------------- 10 | TX_PIN PIN 30 INPUT 11 | RX_PIN PIN 31 INPUT 12 | 13 | ' ---------------------------------------------------------------------- 14 | ' GLOBAL: Constants 15 | ' ---------------------------------------------------------------------- 16 | ' -- !!! You HAVE TO use Variables for the BAUD Rate/s 17 | Terminal_Baud CON 115200 18 | 19 | ' -- "TX_RX_Format_Lib_.pbas" Constants --------------- 20 | HOME CON 1 21 | CR CON 13 22 | CLS CON 16 23 | 24 | ' ---------------------------------------------------------------------- 25 | ' GLOBAL: HUB Variables (Byte, Word, Long) - use RDxxxx and WRxxxx 26 | ' ---------------------------------------------------------------------- 27 | 28 | Hub_Array HUB WORD(120) ' (2 x 3 x 4 x 5) Single Dimension Array to hold Multi-Dimensional Array Values 29 | 30 | 31 | ' ---------------------------------------------------------------------- 32 | ' GLOBAL: DATA, WDATA, LDATA, FILE - use RDxxxx and WRxxxx 33 | ' ---------------------------------------------------------------------- 34 | 35 | 36 | ' ---------------------------------------------------------------------- 37 | ' COG 0: Variables (Long only) 38 | ' ---------------------------------------------------------------------- 39 | TX_BAUD VAR LONG 40 | RX_BAUD VAR LONG 41 | 42 | 43 | Xe CON 2 ' Number of Elements in X Dimension 44 | Ye CON 3 ' Number of Elements in Y Dimension 45 | Ze CON 4 ' Number of Elements in Z Dimension 46 | Te CON 5 ' Number of Elements in T Dimension 47 | 48 | X_Loop CON (Xe - 1) ' Number of Elements Loop limit for X Dimension 49 | Y_Loop CON (Ye - 1) ' Number of Elements Loop limit for Y Dimension 50 | Z_Loop CON (Ze - 1) ' Number of Elements Loop limit for Z Dimension 51 | T_Loop CON (Te - 1) ' Number of Elements Loop limit for T Dimension 52 | 53 | ' Array VAR LONG(120) ' (2 x 3 x 4 x 5) Single Dimension Array to hold Multi-Dimensional Array Values 54 | 55 | Xi VAR LONG ' Calculated X Index for the Array 56 | Yi VAR LONG ' Calculated Y Index for the Array 57 | Zi VAR LONG ' Calculated Z Index for the Array 58 | 59 | Idx VAR LONG ' Calculated Index for the Single Dimension Array 60 | 61 | Xc VAR LONG ' X Co-ordinate 62 | Yc VAR LONG ' Y Co-ordinate 63 | Zc VAR LONG ' Z Co-ordinate 64 | Tc VAR LONG ' T Co-ordinate 65 | 66 | Temp VAR LONG 67 | 68 | 69 | 70 | ' ---------------------------------------------------------------------- 71 | ' COG 0: SUB & FUNC Definitions 72 | ' ---------------------------------------------------------------------- 73 | LOAD "D:\Propeller\Propeller Programs\Libraries\DELAYS_LIB.pbas" 74 | LOAD "D:\Propeller\Propeller Programs\Libraries\TX_RX_LIB.pbas" 75 | 76 | Calc_4_Dim_Index SUB 0 77 | Write_Array SUB 1 78 | Read_Array FUNC 0 79 | 80 | 81 | 82 | 83 | ' ---------------------------------------------------------------------- 84 | ' TASK Definitions 85 | ' ---------------------------------------------------------------------- 86 | 87 | 88 | ' ====================================================================== 89 | PROGRAM START 90 | ' ====================================================================== 91 | 92 | START: 93 | 94 | TX_BAUD = Terminal_Baud 95 | RX_BAUD = Terminal_Baud 96 | 97 | DELAY_MS 3000 98 | TX_BYTE CLS 99 | DELAY_MS 1000 100 | 101 | 102 | ' -- Clear the Array 103 | FOR Xc = 0 TO X_Loop 104 | 105 | FOR Yc = 0 TO Y_Loop 106 | 107 | FOR Zc = 0 TO Z_Loop 108 | 109 | FOR Tc = 0 TO T_Loop 110 | 111 | GOSUB Write_Array, 0 ' Value 112 | 113 | NEXT 114 | 115 | NEXT 116 | 117 | NEXT 118 | 119 | NEXT 120 | 121 | 122 | 123 | 124 | ' -- Write to the Array 125 | FOR Xc = 0 TO X_Loop 126 | 127 | FOR Yc = 0 TO Y_Loop 128 | 129 | FOR Zc = 0 TO Z_Loop 130 | 131 | FOR Tc = 0 TO T_Loop 132 | 133 | GOSUB Calc_4_Dim_Index 134 | 135 | TX_DEC Xc 136 | TX_BYTE " " 137 | TX_DEC Yc 138 | TX_BYTE " " 139 | TX_DEC Zc 140 | TX_BYTE " " 141 | TX_DEC Tc 142 | TX_BYTE " " 143 | TX_DEC Idx 144 | TX_BYTE CR 145 | 146 | GOSUB Write_Array, Idx ' Value 147 | 148 | NEXT 149 | 150 | NEXT 151 | 152 | NEXT 153 | 154 | NEXT 155 | 156 | 157 | TX_BYTE CR 158 | TX_BYTE CR 159 | 160 | 161 | 162 | ' -- Read from the Array 163 | FOR Xc = 0 TO X_Loop 164 | 165 | FOR Yc = 0 TO Y_Loop 166 | 167 | FOR Zc = 0 TO Z_Loop 168 | 169 | FOR Tc = 0 TO T_Loop 170 | 171 | TX_DEC Xc 172 | TX_BYTE " " 173 | TX_DEC Yc 174 | TX_BYTE " " 175 | TX_DEC Zc 176 | TX_BYTE " " 177 | TX_DEC Tc 178 | TX_BYTE " " 179 | 180 | Temp = Read_Array 181 | 182 | TX_DEC Temp 183 | TX_BYTE CR 184 | 185 | NEXT 186 | 187 | NEXT 188 | 189 | NEXT 190 | 191 | NEXT 192 | 193 | 194 | END 195 | 196 | 197 | ' ---------------------------------------------------------------------- 198 | ' COG 0: SUB & FUNC Code 199 | ' ---------------------------------------------------------------------- 200 | 201 | ' ---------------------------------------------------------------------- 202 | SUB Calc_4_Dim_Index 203 | 204 | ' Xi = Xc * Ye * Ze * Te 205 | Xi = Xc * Ye 206 | Xi = Xi * Ze 207 | Xi = Xi * Te 208 | 209 | ' Yi = Yc * Ze * Te 210 | Yi = Yc * Ze 211 | Yi = Yi * Te 212 | 213 | ' Zi = Zc * Te 214 | Zi = Zc * Te 215 | 216 | ' Idx = Xi + Yi + Zi + Tc 217 | Idx = Xi + Yi 218 | Idx = Idx + Zi 219 | Idx = Idx + Tc 220 | 221 | ENDSUB 222 | 223 | 224 | 225 | 226 | 227 | ' ---------------------------------------------------------------------- 228 | SUB Write_Array 229 | 230 | GOSUB Calc_4_Dim_Index 231 | 232 | ' Array(Idx) = __param1 233 | 234 | WRWORD Hub_Array(Idx), __param1 235 | 236 | ENDSUB 237 | 238 | 239 | 240 | ' ---------------------------------------------------------------------- 241 | FUNC Read_Array 242 | 243 | GOSUB Calc_4_Dim_Index 244 | 245 | ' __param1 = Array(Idx) 246 | 247 | RDWORD Hub_Array(Idx), __param1 248 | 249 | RETURN __param1 250 | 251 | ENDFUNC 252 | 253 | 254 | 255 | --------------------------------------------------------------------------------