Comments (2)
Hi @wf58585858 Apologies for the slow response. I'll take a look at this over the weekend and see if I can fix both issues!
from phpi.
Thank you for the response!
Based on my research, I found that the official OS from Raspberry Pi is more compatible with Raspberry Pi, so I switched to using the official OS.
Additionally, I have a few optimization suggestions. Please see if you can consider adopting them, if it's not too much trouble.
-
PHP has now reached version 8.3. It may be worth compiling various releases of https://github.com/calcinai/php-ext-mmap to make it easier for those in need to use. So far, I haven't found a library that can replace this functionality, so your library might be helpful to many people.
-
Open a project on packagist.org to provide fread(), fwrite(), fseek(), fclose() for mmap, with OS files directly placed in the PHP source code and imported using the dl function. This approach is only effective in CLI. If users are using php-fpm, give them a prompt to configure it in php.ini. Basically, if there are no bug-related issues, maintenance may not be necessary in the future.
-
Update https://github.com/calcinai/phpi to adapt to PHP 8 syntax and Raspberry Pi 5. Syntax before PHP 7.4 can be disregarded for compatibility. Import mmap via Composer so that Python-related issues are not a concern. After all, if someone knows Python, they might not need this project.
┌─[root@raspberrypi] - [/sys/class/gpio] - [2024-04-10 03:53:00]
└─[0] <> lla
total 0
drwxrwxr-x 2 root gpio 0 2024/04/04 11:19:42 ./
drwxr-xr-x 65 root root 0 1970/01/01 01:00:03 ../
--w--w---- 1 root gpio 4.0K 2024/04/04 11:19:42 export
lrwxrwxrwx 1 root gpio 0 2024/04/04 11:19:42 gpiochip512 -> ../../devices/platform/soc/3f200000.gpio/gpio/gpiochip512/
lrwxrwxrwx 1 root gpio 0 2024/04/04 11:19:42 gpiochip566 -> ../../devices/platform/soc/soc:firmware/soc:firmware:expgpio/gpio/gpiochip566/
--w--w---- 1 root gpio 4.0K 2024/04/04 11:19:42 unexport
You can see that the base number is 512. Many tutorials suggest using echo 10 > /sys/class/gpio/export
to export a pin.
In my case this doesn't work; I have to use echo 522 > /sys/class/gpio/export
to export the same pin. So when I operate GPIO, it looks like this:
┌─[root@raspberrypi] - [/sys/class/gpio] - [2024-04-10 03:53:01]
└─[0] <> echo 10 > export
echo: write error: invalid argument
┌─[root@raspberrypi] - [/sys/class/gpio] - [2024-04-10 03:55:15]
└─[1] <> echo 522 > /sys/class/gpio/export
┌─[root@raspberrypi] - [/sys/class/gpio] - [2024-04-10 03:57:16]
└─[0] <> lla
total 0
drwxrwxr-x 2 root gpio 0 2024/04/10 03:57:16 ./
drwxr-xr-x 65 root root 0 1970/01/01 01:00:03 ../
--w--w---- 1 root gpio 4.0K 2024/04/10 03:57:16 export
lrwxrwxrwx 1 root root 0 2024/04/10 03:57:19 gpio522 -> ../../devices/platform/soc/3f200000.gpio/gpiochip0/gpio/gpio522/
lrwxrwxrwx 1 root gpio 0 2024/04/04 11:19:42 gpiochip512 -> ../../devices/platform/soc/3f200000.gpio/gpio/gpiochip512/
lrwxrwxrwx 1 root gpio 0 2024/04/04 11:19:42 gpiochip566 -> ../../devices/platform/soc/soc:firmware/soc:firmware:expgpio/gpio/gpiochip566/
--w--w---- 1 root gpio 4.0K 2024/04/04 11:19:42 unexport
┌─[root@raspberrypi] - [/sys/class/gpio] - [2024-04-10 03:57:19]
└─[0] <> echo 1 > gpio522/value
┌─[root@raspberrypi] - [/sys/class/gpio] - [2024-04-10 03:58:15]
└─[0] <> cat gpio522/value
1
┌─[root@raspberrypi] - [/sys/class/gpio] - [2024-04-10 03:58:28]
└─[0] <>
I've noticed that some Raspberry Pis have this problem while others don't. So I'm not sure if your library can automatically handle this issue.
Do you need to add a setting like setBaseNumber(512)
during initialization?
- In
demo/info.php
, therenderHeader
function can be replaced with the Table class from symfony/console, which is more elegant!
https://symfony.com/doc/current/components/console/helpers/table.html
like this :
use Symfony\Component\Console\Helper\Table;
$table = new Table($output);
$table
->setHeaders(['ISBN', 'Title', 'Author'])
->setRows([
['99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'],
['9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens'],
['960-425-059-0', 'The Lord of the Rings', 'J. R. R. Tolkien'],
['80-902734-1-6', 'And Then There Were None', 'Agatha Christie'],
])
;
$table->render();
from phpi.
Related Issues (12)
- Fix debounce on digital inputs
- HD44780 LCD Compatibility
- SPI Display Functionality
- Support for Matrix LED display
- Fix I2C HOT 6
- Support board revision 900093/BCM2708 HOT 4
- Example on using PWM HOT 8
- Update board detection logic
- raspbian stretch lite 2018-04-18 freeze HOT 33
- Find another way for event detection ? This lib can crash the OS. HOT 3
- Support for Board revision [b03114/BCM2711] HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phpi.