Skip to content

Locoduino/ArduiEmulatorWin

Repository files navigation

= Arduino Emulator =

This is a program for Windows to emulate Arduino behaviour.

== License ==

Copyright (c) 2017-2019 Locoduino.org. All right reserved. Copyright (c) 2017-2019 Thierry Paris. All right reserved.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

The goal of this program is to emulate the behaviour of an Arduino. This is a stand alone program, built to receive messages through interprocess communications from the Arduino program itself.

There is two parts in this program.

First, a C# Windows executable program, showing the state of all the pins of an Arduino, printing all the console messages, and giving clues about potential problems in the .ino file .

Second, a C++ library to link with the user ino file, building another exe file which will communicates with the Emulator to reflect the current state of the Arduino:

+----------------------+ +----------------------+ | | | ArduiEmulator.lib | | ArduiEmulatorWin.exe | | UserFile.ino | | | -----> | | | The Arduino Emulator | | The user ino file | | ==================== | | ================= | +----------------------+ +----------------------+

To use it, just start the Emulator program and let it wait for messages.

When an Arduino program, coupled with the ArduiEmulator C++ Library, will be launched, the emulator will start to receive messages and react to the orders given by the Arduino program.

The emulator can :

  • Emulate any type of Arduino. For the moment, the available types are Uno R3, Nano R3 and Mega 2560. New types are easy to implement.
  • Digital / Analog pins. Reserved pins (for LCD or SPI...), Interrupt pins are shown.
  • Pin expanders (SX1509, 74HC595 ...) are also emulated.
  • LCD screen up to 5 lines of 60 characters, driven through LiquidCrystal library.
  • Serial console for messages from and to the Arduino.
  • Debug console for errors and warnings during Arduino program execution.
  • Any pin state can be changed by the user, and this change will be sent back to the Arduino Program.

There is six areas in the program window.

+------------------------------------------+----+ | | | | | | | 1 | | | | | +------------------------------------------+ | | | | | | | | | | | 2 | | | | 5 | | | | | | | +------------------------------------------+ | | 3 | | +------------------------------------------+ | | | | | | | | 4 | | | | | +------------------------------------------+ | | 6 | | +------------------------------------------+----+

1 : On top, the Lcd Simulator, reacting to orders given through the library LiquidCrystal delivered by the Arduino IDE classic install. 2 : Serial console, similar to the one of IDE. 3 : This is a text input field. OPn the left a 'Serial' button will send this text to the Arduino program as serial data. On the right, a 'Pins' button to send ionstruction to the emulator :

EXP id pinnb type "name" : new expander
												where id is the unic expander id.
												where pinb is total number of pins forthis expander.
												where type is the default input/output mode.
												and 'name' is the ... name !
PM pinnb expid type		: pinMode 
												where pinnb is a pin number, 
												where expid is an expander id, 0 for Arduino pin.
												and type a 'O' for output, 'I' for input, 'IP' for input_pullup
PS pinnb expid value		: Move pin value
												where pinnb is a pin number, 
												where expid is an expander id, 0 for Arduino pin.
												and value the new value of the pin : digital 0 for LOW and 1 for HIGH, and the value [0-4095] in analog.
PN pinnb expid "name"	: Change pin name
												where pinnb is a pin number, 
												where expid is an expander id, 0 for Arduino pin.
												and name the new name of the pin.
SC "string"						: Serial print
												where "string" has to be printed to the serial console without the '"' ...
DB "string"						: Debug print
												where "string" has to be printed to the debug console without the '"' ...
RS 										: Reset the emulator to empty default, to start a new emulation.
TP 										:	Internally declare some pins and expander pins to test the emulator...

LCD BG rows cols 			: begin()
												where row is the row number
												where col is the column number
LCD CL 								: clear() the screen
LCD HOME 							: home() : Set the cursor to 0,0
LCD WR 'char' 				: write()
												where char is the character to output at the current cursor position.
LCD PR row col "mess"	: print() or setCursor()
											where row is a row number
											where col is a column number
											and mess the text to print, surrounded by double quotes. If no text, do a setCursor only.
LCD SC cols 					: scrollToRight() / scrollToLeft()
											where cols is the number of columns : positive to move to the right, negative to the left.
LCD DISP bool 				: display() / noDisplay()
											where bool means display if true, or hide (no display) if false;
LCD SCDISP bool				:	scrollDisplayToLeft() / scrollDisplayToRight()
											where bool means scroll display to left if true (default), or scroll display to right if false;
LCD BLK bool					: blink() / noBlink()
											where bool means blink if true, or no blink if false;
LCD CSR bool					: cursor() / noCursor()
											where bool means cursor if true, or no cursor if false;
LCD LTOR bool					: leftToRight() / rightToLeft()
											where bool means Left to Right if true (default), or Right to Left if false;
LCD AUTOSC 						: autoScroll() / noAutoscroll()
											where bool means autoscroll if true, or no autoscroll if false;

4 The debug console. Each problem send a message here : invalid pin number, pin initialized two times, etc...

5 Pin area. This is the active pin list, each pin with a pinMode or an analogRead will be shown here. Teh user can double click on a pin to change its state. In this case, a message is sent to the Arduino program to let him keep an updated state of this pin.

6 The last area... On extreme left, a small red Arduino logo will light up to green when an Aruino program is detected. Then a combo is available to choose the Arduino Model. Of course, it is better to choose the model before launching the Arduino program ! Then a check box called 'debug' can be used to print to the debug console all the messages exchanged between Arduino Emulator and the Arduino Program. At least, a 'About' button will give you the version of the Arduino Emulator. Inside the about box, a small button 'News' on the right bottom will show the "What's New" file, available in ArduiEmulatorWin directory.

About

Arduino Emulator Main Program

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published