PHP code example of dept-of-scrapyard-robotics / jd79661

1. Go to this page and download the library: Download dept-of-scrapyard-robotics/jd79661 library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dept-of-scrapyard-robotics / jd79661 example snippets



use DeptOfScrapyardRobotics\Displays\JD79661\JD79661\JD79661;

return [
    'displays' => [
        // For Native Configurations 
        'jd79661-native' => [
            'class_name' => JD79661::class,
            'connection' => ['driver' => 'native'],
            'startup' => [
                'spi' => [0, 0],
                'gpiochip' => [0],
                'rst' => [24],
                'dc' => [22],
                'busy' => [17],
            ],
        ],
        // For USB Configurations
        'jd79661-usb' => [
            'class_name' => JD79661::class,
            'connection' => ['driver' => 'usb'],
            'startup' => [
                'spi' => ['ft232h', 0],
                'gpiochip' => ['ft232h'],
                'rst' => [0],
                'dc' => [1],
                'busy' => [2],
            ],
        ],        
    ]
];


use DeptOfScrapyardRobotics\Displays\JD79661\JD79661\JD79661;

$native_spi_display = JD79661::connection('native')
    ->spi(0, 0)
    ->gpiochip(0)
    ->rst(24)
    ->dc(22)
    ->busy(17)
    ->create()


use DeptOfScrapyardRobotics\Displays\JD79661\JD79661\JD79661;

$usb_spi_display = JD79661::connection('usb')
    ->spi('ft232h', 0)
    ->gpiochip('ft232h')
    ->rst(0)
    ->dc(1)
    ->busy(2)
    ->create()

use DeptOfScrapyardRobotics\Displays\JD79661\JD79661\JD79661;
use RealityInterface\Displays\Applied\ePaper\QuadColorePaperDisplay;

$jd79661 = JD79661::connection('usb')
    ->spi('ft232h', 0)
    ->gpiochip('ft232h')
    ->rst(0)
    ->dc(1)
    ->busy(2)
    ->create()
    
$display = QuadColorePaperDisplay::as($jd79661);



use RealityInterface\Displays\Applied\ePaper\QuadColorePaperDisplay;

$display = QuadColorePaperDisplay::using('jd79661-usb');


use DeptOfScrapyardRobotics\Displays\JD79661\JD79661\JD79661;
use Microscrap\GFX\PhpdaFruit\GFXRenderer;
use RealityInterface\Displays\Applied\ePaper\Buffers\ChannelSortedFrameBuffer;
use RealityInterface\Displays\Applied\ePaper\Enums\EInkColor;
use RealityInterface\Displays\Applied\ePaper\QuadColorePaperDisplay;
use RealityInterface\Displays\Screen;

$jd79661 = JD79661::connection('usb')
    ->spi('ft232h', 0)
    ->gpiochip('ft232h')
    ->rst(0)
    ->dc(1)
    ->busy(2)
    ->create();

$display = QuadColorePaperDisplay::as($jd79661);

$buffer = new ChannelSortedFrameBuffer($display->width(), $display->height(), $display->getFormatSpec());
$screen = new Screen($display, new GFXRenderer($buffer));

$screen
    ->fill(EInkColor::WHITE->value)
    ->drawRect(0, 0, $display->width(), $display->height(), EInkColor::BLACK->value)
    ->fillCircle(intdiv($display->width(), 2), 40, 18, EInkColor::RED->value)
    ->setTextColor(EInkColor::BLACK->value)
    ->setCursor(8, 80)
    ->print('JD79661')
    ->setTextColor(EInkColor::YELLOW->value)
    ->setCursor(8, 100)
    ->print('B/W/R/Y')
    ->render();