Skip to content

Commit

Permalink
doc
Browse files Browse the repository at this point in the history
  • Loading branch information
ponty committed Nov 2, 2015
1 parent 9532dd9 commit 880e984
Show file tree
Hide file tree
Showing 10 changed files with 221 additions and 268 deletions.
159 changes: 157 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ Ubuntu 14.04
sudo apt-get install python-pip
sudo apt-get install swig python-dev gcc libelf-dev arduino
sudo pip install pysimavr
# optional for examples:
sudo pip install entrypoint2
# optional for some tests:
sudo apt-get install freeglut3-dev scons

Expand All @@ -94,6 +92,163 @@ Uninstall
# as root
pip uninstall pysimavr

Usage
=====

pysimavr.examples.simple::
#-- include('examples/simple.py')--#
from pysimavr.avr import Avr

if __name__ == "__main__":
avr = Avr(mcu='atmega48', f_cpu=8000000)
print( avr.pc )
avr.step(1)
print( avr.pc )
avr.step(1)
print( avr.pc )
avr.terminate()
#-#

Output::

#-- sh('python -m pysimavr.examples.simple ')--#
0
2
4
#-#

pysimavr.examples.hello::
#-- include('examples/hello.py')--#
from pysimavr.sim import ArduinoSim

if __name__ == "__main__":
s= ArduinoSim(snippet='Serial.println("hello!");').get_serial()
print(s)
#-#

Output::

#-- sh('python -m pysimavr.examples.hello ')--#
hello!

#-#

pysimavr.examples.delay::
#-- include('examples/delay.py')--#
from pysimavr.sim import ArduinoSim
import time

snippet = '''
int i=0;
while (1)
{
Serial.println(i++);
_delay_ms(1000);
}
'''
t0 = None


def logger(x):
global t0
t = time.time()
if not t0:
t0 = t
print t - t0, x


f_cpu=16000000
fps=20
speed=1
timespan=5

if __name__ == "__main__":
ArduinoSim(snippet=snippet,
timespan=timespan,
serial_line_logger=logger,
f_cpu=f_cpu,
fps=fps,
speed=speed,
).run()
#-#

Output::

#-- sh('python -m pysimavr.examples.delay ')--#
0.0 0

1.00977802277 1

2.01976013184 2

3.02968215942 3

4.03792500496 4

#-#

vcd export example
------------------

pysimavr.examples.vcd::

#-- include('examples/vcd.py')--#
from pysimavr.sim import ArduinoSim


vcdfile='delay.vcd'
snippet = '''
Serial.println("start");
pinMode(0, OUTPUT);
digitalWrite(0, HIGH);
delay(100);
digitalWrite(0, LOW);
delay(100);
digitalWrite(0, HIGH);
delay(100);
digitalWrite(0, LOW);
delay(100);
Serial.println("end");
'''

if __name__ == "__main__":
sim = ArduinoSim(snippet=snippet, vcd=vcdfile, timespan=0.5)
sim.run()
#-#

.. image:: gtkwave_id0.png

File hierarchy
==============

::
|-docs sphinx documentation
|---.build generated documentation
|-pysimavr main python package, high level classes
|---examples examples
|---swig all swig files (simavr and parts)
|-----include copy of simavr generated *.h files
|-------avr copy from avr-libc
|-----parts some electronic parts in c
|-----simavr simavr as git submodule
|-tests unit tests



How to update external sources
==============================

1. copy avr-libc headers (Ubuntu folder: /usr/lib/avr/include/avr/) into pysimavr/swig/include/avr
2. simavr is a git submodule. Run 'make' inside simavr directory,
then copy generated sim_core_config.h and sim_core_decl.h into pysimavr/swig/include




.. _setuptools: http://peak.telecommunity.com/DevCenter/EasyInstall
.. _pip: https://pypi.python.org/pypi/pip
Expand Down
40 changes: 0 additions & 40 deletions docs/files.rst

This file was deleted.

24 changes: 8 additions & 16 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
**pysimavr**
========
pysimavr
========

:Date: |today|
:PDF: `pysimavr.pdf <pysimavr.pdf>`_


Contents:
About
=====

.. toctree::
:maxdepth: 2

readme
usage
files
api

Indices and tables
==================
.. include:: ../README.rst

.. include:: api.rst

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

41 changes: 0 additions & 41 deletions docs/usage.rst

This file was deleted.

Loading

0 comments on commit 880e984

Please sign in to comment.