Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {{
- ─────────────────────────────────────────────────
- File: BadgeMonitor_v1_0.spin
- Version: 1.0
- Copyright (c) 2016 Tymkrs
- See end of file for terms of use.
- Author: Whisker
- ─────────────────────────────────────────────────
- }}
- {
- HISTORY:
- This driver is made as an example for using the Badge Bug to monitor a Cyphercon2016 badge over a serial port
- USAGE:
- • Install Badge Bug
- • Flash this firmware to the Badge Bug (via Propeller Tool & Prop Plug, etc.)
- • Use a serial terminal emulator and a usb ttl serial cable to talk to Badge Bug at 115200 baud
- • Parse the incoming data to use the badge as a controller?
- }
- Con
- _clkmode = xtal1 + pll16x
- _xinfreq = 5_000_000
- OBJ
- fds : "FullDuplexSerial"
- VAR
- long PreviousStates, PinName, PinNameEnd
- Pub Main | Index
- Init
- repeat
- ScanEvents
- Pub ScanEvents | Index
- dirb := ina ^ PreviousStates
- PreviousStates := ina
- repeat Index from 0 to 31
- case Index
- 0..12, 16..23:
- if dirb[Index] == 1
- SetPinName(Index)
- fds.Str(@PinName)
- if ina[Index] == 0
- fds.Str(String("0"))
- elseif ina[Index] == 1
- fds.Str(String("1"))
- Pub SetPinName(PinOffset) | Index
- repeat Index from 0 to 3
- BYTE[@PinName][Index] := BYTE[@PinKey][(Pinoffset * 4) + Index]
- PinNameEnd := 0
- Pub Init
- fds.Start(31, 30, 0, 115_200)
- waitcnt((clkfreq / 1000) + cnt)
- DAT
- PinKey byte "SR_0SR_1SR_2SR_3SR_4SR_5SR_6SR_7STEPDATAIN_0IN_1IN_2 KEY0KEY1KEY2XOR0XOR1XOR2TAPATAPB "
- {{
- ┌──────────────────────────────────────────────────────────────────────────────────────┐
- │ TERMS OF USE: MIT License │
- ├──────────────────────────────────────────────────────────────────────────────────────┤
- │Permission is hereby granted, free of charge, to any person obtaining a copy of this │
- │software and associated documentation files (the "Software"), to deal in the Software │
- │without restriction, including without limitation the rights to use, copy, modify, │
- │merge, publish, distribute, sublicense, and/or sell copies of the Software, and to │
- │permit persons to whom the Software is furnished to do so, subject to the following │
- │conditions: │
- │ │
- │The above copyright notice and this permission notice shall be included in all copies │
- │or substantial portions of the Software. │
- │ │
- │THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, │
- │INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A │
- │PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT │
- │HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION │
- │OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
- │SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
- └──────────────────────────────────────────────────────────────────────────────────────┘
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement