140 likes | 245 Views
OOPic (Object Oriented Pic). Dominick D’Aniello Jacques Bosman. Overview. What is the OOPic? What Makes the OOPic Different? Hardware Objects Virtual circuits Events The OOPic IDE The OOPic Language Demo. What is the OOPic?.
E N D
OOPic (Object Oriented Pic) Dominick D’Aniello Jacques Bosman
Overview • What is the OOPic? • What Makes the OOPic Different? • Hardware Objects • Virtual circuits • Events • The OOPic IDE • The OOPic Language • Demo
What is the OOPic? • 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? 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 • 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 oLCD Object. LCD.Init ' Initialize the LCD Module. LCD.Clear ' Clear the screen. LCD.Locate(0,1) ' Locate cursor at row1, col2. 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 Button1 As New oDIO1 Dim Button2 As New oDIO1 Dim RedLed As New oDIO1 Dim AndGate As New oGate(2) Button1.IOLine = 1: Button1.Direction = cvInput Button2.IOLine = 2: Button2.Direction = cvInput RedLed.IOLine = 3: RedLed.Direction = cvOutput AndGate.Input1.Link(Button1.Value) AndGate.Input2.Link(Button2.Value) AndGate.Output.Link(RedLed.Value)
Events • The OOPic supports events (interrupts) through the oEvent object • Event is triggered when the oEvent 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 oEvent 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 Languages • 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) • 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 Java/C++ Dim A As New oDio1 Sub Main() A.IOLine = 31 A.Direction = cvOutput Call Blink Call Blink End Sub Sub Blink() A.Value = cvON OOPic.Wait = 100 A.Value = cvOff OOPic.Wait = 100 End Sub oDio1 A = New oDio1; Sub void main(void) { A.IOLine = 31; A.Direction = cvOutput; Blink(); Blink(); } Sub void Blink(void) { A.Value = cvON; OOPic.Wait = 100; A.Value = cvOff; OOPic.Wait = 100; }
Demo • oDio1 LED[8] = New oDio1; • oWire wires[4] = New oWire; • Sub void Main(void) • { • OOPic.Node = 2; • oByte I = New oByte; • for (I.Value = 1; I.Value <= 8; I.Value++) • { • LED[I.Value].IOLine = (I.Value + 7); • LED[I.Value].Direction = cvOutput; • LED[I.Value].set; • } • wires[1].Input.Link(OOPic.Hz1); • wires[1].Output.Link(LED[5]); • wires[1].InvertIn = cvFalse; • wires[1].Operate = cvTrue; • wires[2].Input.Link(OOPic.Hz1); • wires[2].Output.Link(LED[6]); • wires[2].InvertIn = cvTrue;
Demo • wires[2].Operate = cvTrue; • wires[3].Input.Link(OOPic.Hz1); • wires[3].Output.Link(LED[7]); • wires[3].InvertIn = cvFalse; • wires[3].Operate = cvTrue; • wires[4].Input.Link(OOPic.Hz1); • wires[4].Output.Link(LED[8]); • wires[4].InvertIn = cvTrue; • wires[4].Operate = cvTrue; • Do • { • 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); • }