OOPic Object Oriented Pic Dominick DAniello Jacques Bosman
OOPic (Object Oriented Pic) Dominick D’Aniello Jacques Bosman
Overview l l What is the OOPic? What Makes the OOPic Different? – – – l l l Hardware Objects Virtual circuits Events The OOPic IDE The OOPic Language Demo
What is the OOPic? l l l OOPic is an object oriented operating system (and hardware circuit) Programmed in a Basic like or Java/C++ style language Capable of inter-OOPic communications
What makes the OOPic different? l l Physically, the OOPic is nothing more than a Microchip™ Pic microcontroller slapped on a circuit board with some EEPROM and a few pin headers for easy access to the Pic’s pins. What makes the OOPic unique is the software it runs. The OOPic software allows one to interact with physical hardware, as if it were a OOP software object. + =
Hardware Objects l l l OOPic offers many pre-made “Hardware objects” that provide software mappings to real world hardware. Objects include something as simple as 1 bit digital IO (An LED or a switch) to something as non trivial as an LCD or a stepper motor. Allows for intuitive statements such as: LCD. Operate = 1 ' Turn on the o. LCD Object. LCD. Init ' Initialize the LCD Module. LCD. Clear ' Clear the screen. LCD. Locate(0, 1) ' Locate cursor at row 1, col 2. LCD. String = "Hello World" ' Print "Hello World" on LCD.
Virtual Circuits OOPic allows you to create multiple “Virtual circuits” that run independently of each other and your running code. Dim Button 1 As New o. DIO 1 Dim Button 2 As New o. DIO 1 Dim Red. Led As New o. DIO 1 Dim And. Gate As New o. Gate(2) Button 1. IOLine = 1: Button 1. Direction = cv. Input Button 2. IOLine = 2: Button 2. Direction = cv. Input Red. Led. IOLine = 3: Red. Led. Direction = cv. Output And. Gate. Input 1. Link(Button 1. Value) And. Gate. Input 2. Link(Button 2. Value) And. Gate. Output. Link(Red. Led. Value)
Events l l l The OOPic supports events (interrupts) through the o. Event object Event is triggered when the o. Event objects operate value goes from 0 to 1. When the even is triggered the procedure with the same name as the event, followed by “_code” is executed, for example if you have an o. Event object named “bump”, then the procedure named “bump_code” would execute when bump. operate = 1. Events can have different priorities (lower priorities have precedence) Events interrupt current program flow, when they return, program flow resumes where it left off.
The OOPic IDE The OOpic IDE offers simple editing, flashing, and debugging features. Code is shown on the left, objects represented in the code are shown on the right. When the OOPic is connected to the computer you can click on any of the objects in the right hand panel to view and manipulate their current state.
The OOPic IDE (Cont)
The OOPic Languages l l l The OOPic offers 3 basic language modes (Basic and Java/C++ style). The BASIC style is fairly true to traditional BASIC syntax, however the Java/C++ style is only very loosely related to actual Java and C++ syntax (Basically it has ; ’s) Java and C++ languages types are technically treated differently, but VERY few differences exist.
The OOPic Languages (cont) l l Supports all basic loop and control structures (If/then/else, switch, for, do/while) Procedures support recursion (limited only by stack space) Supports arrays of any object type (Arrays are indexed starting at 1, not 0) Supports user defined objects
The OOPic Languages (cont) BASIC Dim A As New o. Dio 1 Sub Main() A. IOLine = 31 A. Direction = cv. Output Call Blink End Sub Blink() A. Value = cv. ON OOPic. Wait = 100 A. Value = cv. Off OOPic. Wait = 100 End Sub Java/C++ o. Dio 1 A = New o. Dio 1; Sub void main(void) { A. IOLine = 31; A. Direction = cv. Output; Blink(); } Sub void Blink(void) { A. Value = cv. ON; OOPic. Wait = 100; A. Value = cv. Off; OOPic. Wait = 100; }
Demo 1. 2. o. Dio 1 LED[8] = New o. Dio 1; o. Wire wires[4] = New o. Wire; 3. Sub void Main(void) { OOPic. Node = 2; o. Byte I = New o. Byte; 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. for (I. Value = 1; I. Value <= 8; I. Value++) { LED[I. Value]. IOLine = (I. Value + 7); LED[I. Value]. Direction = cv. Output; LED[I. Value]. set; } 14. 15. 16. 17. wires[1]. Input. Link(OOPic. Hz 1); wires[1]. Output. Link(LED[5]); wires[1]. Invert. In = cv. False; wires[1]. Operate = cv. True; 18. 19. 20. wires[2]. Input. Link(OOPic. Hz 1); wires[2]. Output. Link(LED[6]); wires[2]. Invert. In = cv. True;
Demo 21. wires[2]. Operate = cv. True; 22. 25. wires[3]. Input. Link(OOPic. Hz 1); wires[3]. Output. Link(LED[7]); wires[3]. Invert. In = cv. False; wires[3]. Operate = cv. True; 26. 27. 28. 29. wires[4]. Input. Link(OOPic. Hz 1); wires[4]. Output. Link(LED[8]); wires[4]. Invert. In = cv. True; wires[4]. Operate = cv. True; 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. Do { 23. 24. for (I. Value = 1; I. Value <= 4; I. Value++) { LED[I. Value]. value = 0; OOPic. delay = 20; LED[I. Value]. value = 1; OOPic. delay = 20; } } while (1); }
- Slides: 14