Hello, welcome to the world of cross-deleveopment. Depending on what you want to achieve, there are different strategies:
(A) develop on computer, transfer to pi and test on pi. Run on pi.
(B) develop on computer, test on computer using mockup, transfer to pi and test on pi. Run on pi.
(C) develop on computer, test on computer using connection to a pi's GPIO, transfer to pi and test on pi. Run on pi.
(D) develop on computer, test on computer using connection to a pi's GPIO, run on computer with a pi's GPIO.
(A) is very simple. Just write your code on computer and accept that eclipse is showing errors that libs are not found. Transfer to pi and test there. As python code does not need to be compiled, this is easy. When problems found, correct on computer and transfer again. A tedious process, but when you automate the transfer and execution within eclipse, it is quite straightforward.
(B) I usually develop in eclipse on a laptop. The hardware access is in one class, which has two implementations: one for the pi using GPIO, the other is for the development environment.
Code: Select all
import RPi.GPIO as gpio
mockup = False
mockup = True
MOTOR_PIN = 18
hardware = HardwareMockup()
hardware = HardwareGPIO()
Unfortunately, the idea of 'interfaces' and 'implementing classes' is not very good in python. But you see the idea: classes with same methods but completely different internal implementation.
For inputs, it is getting more complicated.
(C) when on computer the programm should be fully testable, then use an access method which is both available on computer on pi. pigpiod allows remote access. This runs same way on both remote and local environment. Possibly GPIO Zero has the same features.
(D) this is less cross development but remote execution. Remote access to a pi is needed. Either use low level GPIO access on a pi, or work with a small layer of code on the pi which allows to execute fast thinks on pi but control is performed by remote computer.