Follow instructions of Unosquare RaspberryIO documentation
sudo apt-get install automake
sudo apt-get install libtool
sudo apt-get install libglib2.0-dev
sudo apt-get install libxrender-dev
sudo apt-get install libfontconfig1-dev
sudo apt-get install libpng12-dev
sudo apt-get install libgif-dev
sudo apt-get install libjpeg8-dev
sudo apt-get install libtiff5-dev
sudo apt-get install libexif-dev
sudo apt-get install gettext
You can find a Nokia 5110 LCD on sparkfun or on hackspark.
You can follow instructions of this article
Pin number | GPIO | LCD PIN |
---|---|---|
18 | GPIO 24 | RST |
24 | SPI_CE0 | CE |
16 | GPIO 23 | DC |
19 | SPI_MOSI | DIN |
23 | SPI_SCLK | CLK |
1 | VCC 3.3V (+) | VCC |
11 | GPIO 17 | LIGHT |
6 | GND (-) | GND |
You need to enable SPI.
You can use sudo raspi-config
as explained here
I you followed the previous wiring instructions then you can use ScreenContext.Default
to control your screen.
Your bitmap must have a width of 84 pixels and a height of 48 pixels.
Color are not interpreted. If a pixel is not black, then it is displayed. Images are encoded with one bit per pixel. So a buffer of 504 bytes is sent to the screen.
Now we will display this bitmap.
Code is:
let logo = Bitmap.FromFile "logo2.bmp" :?> Bitmap
ScreenContext.Default
|> start (60uy, 4uy) // 60 is contrast, 4 is the bias
|> displayImage logo
|> ignore
Result is:
let text =
{ Text.From "FSharp works on Raspberry Pi !"
with Font = new Font("Roboto", 10.f)
}
ScreenContext.Default
|> start (60uy, 4uy) // 60 is contrast, 4 is the bias
|> displayText text
|> ignore
Example program is here
Build project with
cd RaspberryFsharp.Lcd5110.Sample
dotnet build
dotnet publish -r linux-arm
Upload manually.
You can also use sshdeploy
like
dotnet sshdeploy push -w youpassword -h yourip
You also edit the project to store informations
I made a pull request to add support of FSharp project. I am now waiting for the new version a the NuGet
chmod +x RaspberryFsharp.Lcd5110.Sample
sudo ./RaspberryFsharp.Lcd5110.Sample