Skip to content

Commit

Permalink
fix some errors
Browse files Browse the repository at this point in the history
  • Loading branch information
xiemeiping committed Dec 24, 2021
1 parent 30b73a4 commit 6623613
Show file tree
Hide file tree
Showing 35 changed files with 887 additions and 15 deletions.
3 changes: 2 additions & 1 deletion docs/source/binary_game.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ Lesson Guide
Arrange a small binary abacus at the bottom of the screen.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

First, we delete the previous sprite. Upload the **Zero.png** file and **Enter.png** file in the sprite list, you have downloaded them from `github - 10.1-touch-screen <https://github.com/sunfounder/10.1-touch-screen>`_ before.
First, we delete the previous sprite. Upload the **Zero.png** file and **Enter.png** file in the sprite list, you have downloaded them from `github -
7-diy-touch-screen <https://github.com/sunfounder/7-diy-touch-screen>`_ before.

Then we upload the **One.png** file in the **Costumes** option of the **Zero** sprite, so that the **Zero** sprite has **Zero** costume and **One** costume.

Expand Down
6 changes: 3 additions & 3 deletions docs/source/iot/projects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Open a Terminal and enter the following command to download them from github.

<run></run>

.. code-block::
.. code-block:: shell
git clone https://github.com/sunfounder/10.1-touch-screen
git clone https://github.com/sunfounder/7-diy-touch-screen
Then copy the codes from the ``iot`` folder to the ``cloud4rpi-raspberrypi-python`` folder.

Expand All @@ -23,7 +23,7 @@ Then copy the codes from the ``iot`` folder to the ``cloud4rpi-raspberrypi-pytho

.. code-block:: shell
cp -r /home/pi/10.1-touch-screen/iot/* /home/pi/cloud4rpi-raspberrypi-python
cp -r /home/pi/7-diy-touch-screen/iot/* /home/pi/cloud4rpi-raspberrypi-python
.. toctree::
Expand Down
3 changes: 2 additions & 1 deletion docs/source/paint_box.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ Lay out the drawing board, add Pen expansion function

First, we delete the previous sprite, and then add the Pencil sprite and Block-X sprite to Scratch.

Upload **Eraser.svg, Red.png, Blue.png, Green.png, Yellow.png** and other files in the Sprite list (You have downloaded from `github - 10.1-touch-screen <https://github.com/sunfounder/10.1-touch-screen>`_ before.), and finally set the size of the Pencil sprite and Block-X sprite Change to 50.
Upload **Eraser.svg, Red.png, Blue.png, Green.png, Yellow.png** and other files in the Sprite list (You have downloaded from `github -
7-diy-touch-screen <https://github.com/sunfounder/7-diy-touch-screen>`_ before.), and finally set the size of the Pencil sprite and Block-X sprite Change to 50.

.. image:: img/paint_box1.png
:width: 600
Expand Down
50 changes: 43 additions & 7 deletions docs/source/quick_user_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ https://www.raspberrypi.org/documentation/configuration/config-txt.md. 

Reboot the Raspberry pi with the command sudo reboot. 

.. raw:: html

<run></run>

.. code::
sudo reboot
Expand All @@ -89,6 +93,10 @@ When you use a touch panel, you can connect an external keyboard to help you do

Install the required software with the following command.

.. raw:: html

<run></run>

.. code-block:: shell
sudo apt install onboard
Expand Down Expand Up @@ -140,47 +148,75 @@ Here we use ``evdev-rce`` to make right-click command still available.

Enter the following command to install the required software.

.. code-block:: shell
.. raw:: html

<run></run>

.. code-block:: shell
sudo apt install build-essential libevdev2 libevdev-dev
git clone 'https://github.com/PeterCxy/evdev-right-click-emulation.git'
cd 'evdev-right-click-emulation'
Enter the following command to build.

.. code-block:: shell
.. raw:: html

<run></run>

.. code-block:: shell
make all
Copy the file to the ``/usr`` directory.

.. code-block:: shell
.. raw:: html

<run></run>

.. code-block:: shell
sudo cp 'out/evdev-rce' '/usr/local/bin/'
Make it executable.

.. code-block:: shell
.. raw:: html

<run></run>

.. code-block:: shell
sudo chmod +x '/usr/local/bin/evdev-rce'
Modify the /etc/rc.local file to enable boot-up.

.. code-block:: shell
.. raw:: html

<run></run>

.. code-block:: shell
sudo nano /etc/rc.local
After entering rc.local, add the following command before ``exit 0``.

.. raw:: html

<run></run>

.. code-block:: shell
sudo /usr/local/bin/evdev-rce &
sudo /usr/local/bin/evdev-rce &
After restarting, you can long press on the desktop and see if the right click function appears.

.. raw:: html

<run></run>

.. code-block:: shell
sudo reboot
sudo reboot
.. image:: img/right_click.png
:align: center
2 changes: 1 addition & 1 deletion docs/source/retro_games_console.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ The detailed steps are shown in the video:

.. note::

The display for the video is not a 10.1 Touch Screen, it's another one of our products, but the configuration method is the same on the RetroPie.
The display for the video is not a 7inch Touch Screen, it's another one of our products, but the configuration method is the same on the RetroPie.

.. raw:: html

Expand Down
2 changes: 1 addition & 1 deletion docs/source/scratch_programming.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ If you download a system with only a desktop, you can click **Preferences** -> *

.. code-block::
git clone https://github.com/sunfounder/10.1-touch-screen
git clone https://github.com/sunfounder/7-diy-touch-screen
**Projects**

Expand Down
2 changes: 1 addition & 1 deletion docs/source/shooting_game.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Lesson Guide
Arrange the Crosshair and targets.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

First, delete the previous sprite, upload the Crosshair sprite and the target background, you can find them under the path ``10.1-touch-screen/scratch/materials`` (You have downloaded from `github - 10.1-touch-screen <https://github.com/sunfounder/10.1-touch-screen>`_ before.).
First, delete the previous sprite, upload the Crosshair sprite and the target background, you can find them under the path ``7-diy-touch-screen/scratch/materials`` (You have downloaded from `github - 7-diy-touch-screen <https://github.com/sunfounder/7-diy-touch-screen>`_ before.).

Click the icon below the sprite list, select "Upload Sprite Option", find the **Cross Hair.svg** file, and upload it. Similarly, upload the backdrop, **Target.jpg**.

Expand Down
130 changes: 130 additions & 0 deletions iot/ADC0834.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
#!/usr/bin/env python3
#-----------------------------------------------------
#
# This is a program for all ADC chip. It
# convert analog singnal to digital signal.
#
# This program is most analog signal modules'
# dependency. Use it like this:
# `import ADC0834`
# `sig = ADC0834.getResult(chn)`
#
# *'chn' should be 0,1,2,3 represent for ch0, ch1, ch2, ch3
# on ADC0834
#

import RPi.GPIO as GPIO
import time

ADC_CS = 17
ADC_CLK = 18
ADC_DIO = 27

# using default pins for backwards compatibility
def setup(cs=17,clk=18,dio=27):
global ADC_CS, ADC_CLK, ADC_DIO
ADC_CS=cs
ADC_CLK=clk
ADC_DIO=dio
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM) # Number GPIOs by BCM mode
GPIO.setup(ADC_CS, GPIO.OUT) # Set pins' mode is output
GPIO.setup(ADC_CLK, GPIO.OUT) # Set pins' mode is output

def destroy():
GPIO.cleanup()

# using channel = 0 as default for backwards compatibility
def getResult(channel=0): # Get ADC result, input channel

sel = int(channel > 1 & 1)
odd = channel & 1
# print("sel: {}, odd: {}".format(sel, odd))

GPIO.setup(ADC_DIO, GPIO.OUT)
GPIO.output(ADC_CS, 0)

# Start bit
GPIO.output(ADC_CLK, 0)
GPIO.output(ADC_DIO, 1)
time.sleep(0.000002)
GPIO.output(ADC_CLK, 1)
time.sleep(0.000002)

# Single End mode
GPIO.output(ADC_CLK, 0)
GPIO.output(ADC_DIO, 1)
time.sleep(0.000002)
GPIO.output(ADC_CLK, 1)
time.sleep(0.000002)

# ODD
GPIO.output(ADC_CLK, 0)
GPIO.output(ADC_DIO, odd)
time.sleep(0.000002)
GPIO.output(ADC_CLK, 1)
time.sleep(0.000002)

# Select
GPIO.output(ADC_CLK, 0)
GPIO.output(ADC_DIO, sel)
time.sleep(0.000002)
GPIO.output(ADC_CLK, 1)

GPIO.output(ADC_DIO, 1)
time.sleep(0.000002)
GPIO.output(ADC_CLK, 0)
GPIO.output(ADC_DIO, 1)
time.sleep(0.000002)

# ODD
# GPIO.output(ADC_CLK, 0)
# GPIO.output(ADC_DIO, channel)
# time.sleep(0.000002)
# GPIO.output(ADC_CLK, 1)
# GPIO.output(ADC_DIO, 1)
# time.sleep(0.000002)
# GPIO.output(ADC_CLK, 0)
# GPIO.output(ADC_DIO, 1)
# time.sleep(0.000002)

dat1 = 0
for i in range(0, 8):
GPIO.output(ADC_CLK, 1); time.sleep(0.000002)
GPIO.output(ADC_CLK, 0); time.sleep(0.000002)
GPIO.setup(ADC_DIO, GPIO.IN)
dat1 = dat1 << 1 | GPIO.input(ADC_DIO)

dat2 = 0
for i in range(0, 8):
dat2 = dat2 | GPIO.input(ADC_DIO) << i
GPIO.output(ADC_CLK, 1); time.sleep(0.000002)
GPIO.output(ADC_CLK, 0); time.sleep(0.000002)

GPIO.output(ADC_CS, 1)
GPIO.setup(ADC_DIO, GPIO.OUT)

if dat1 == dat2:
return dat1
else:
return 0

def getResult1():
return getResult(1)


def loop():
while True:
for i in range(4):
res = getResult(i)
print ('res{} = {}'.format(i,res))
time.sleep(0.1)
time.sleep(1)

if __name__ == '__main__': # Program start from here
setup()
try:
loop()
except KeyboardInterrupt: # When 'Ctrl+C' is pressed, the child program destroy() will be executed.
destroy()

0 comments on commit 6623613

Please sign in to comment.