From 7310e97ec1092a4e4fd5fb175978ba8135665ca6 Mon Sep 17 00:00:00 2001 From: SSYYL <1032789891@qq.com> Date: Mon, 17 Oct 2022 19:32:48 +0800 Subject: [PATCH] Fixed a few bugs. --- RaspberryPi_JetsonNano/c/lib/GUI/GUI_Paint.c | 63 ++++++++++++++++++- RaspberryPi_JetsonNano/c/lib/GUI/GUI_Paint.h | 1 + RaspberryPi_JetsonNano/c/list.txt | 3 +- .../python/lib/waveshare_epd/epd7in5_V2.py | 2 +- .../python/lib/waveshare_epd/epd7in5b_V2.py | 2 +- .../python/lib/waveshare_epd/epdconfig.py | 1 - 6 files changed, 67 insertions(+), 5 deletions(-) diff --git a/RaspberryPi_JetsonNano/c/lib/GUI/GUI_Paint.c b/RaspberryPi_JetsonNano/c/lib/GUI/GUI_Paint.c index 7512f14..5171233 100644 --- a/RaspberryPi_JetsonNano/c/lib/GUI/GUI_Paint.c +++ b/RaspberryPi_JetsonNano/c/lib/GUI/GUI_Paint.c @@ -717,12 +717,73 @@ void Paint_DrawNum(UWORD Xpoint, UWORD Ypoint, int32_t Nummber, } //Converts a number to a string - while (Nummber) { + do { Num_Array[Num_Bit] = Nummber % 10 + '0'; Num_Bit++; Nummber /= 10; + } while(Nummber); + + + //The string is inverted + while (Num_Bit > 0) { + Str_Array[Str_Bit] = Num_Array[Num_Bit - 1]; + Str_Bit ++; + Num_Bit --; } + //show + Paint_DrawString_EN(Xpoint, Ypoint, (const char*)pStr, Font, Color_Background, Color_Foreground); +} + +/****************************************************************************** +function: Display nummber (Able to display decimals) +parameter: + Xstart :X coordinate + Ystart : Y coordinate + Nummber : The number displayed + Font :A structure pointer that displays a character size + Digit : Fractional width + Color_Foreground : Select the foreground color + Color_Background : Select the background color +******************************************************************************/ +void Paint_DrawNumDecimals(UWORD Xpoint, UWORD Ypoint, double Nummber, + sFONT* Font, UWORD Digit, UWORD Color_Foreground, UWORD Color_Background) +{ + int16_t Num_Bit = 0, Str_Bit = 0; + uint8_t Str_Array[ARRAY_LEN] = {0}, Num_Array[ARRAY_LEN] = {0}; + uint8_t *pStr = Str_Array; + int temp = Nummber; + float decimals; + uint8_t i; + if (Xpoint > Paint.Width || Ypoint > Paint.Height) { + Debug("Paint_DisNum Input exceeds the normal display range\r\n"); + return; + } + + if(Digit > 0) { + decimals = Nummber - temp; + for(i=Digit; i > 0; i--) { + decimals*=10; + } + temp = decimals; + //Converts a number to a string + for(i=Digit; i>0; i--) { + Num_Array[Num_Bit] = temp % 10 + '0'; + Num_Bit++; + temp /= 10; + } + Num_Array[Num_Bit] = '.'; + Num_Bit++; + } + + temp = Nummber; + //Converts a number to a string + do { + Num_Array[Num_Bit] = temp % 10 + '0'; + Num_Bit++; + temp /= 10; + } while(temp); + //The string is inverted while (Num_Bit > 0) { Str_Array[Str_Bit] = Num_Array[Num_Bit - 1]; diff --git a/RaspberryPi_JetsonNano/c/lib/GUI/GUI_Paint.h b/RaspberryPi_JetsonNano/c/lib/GUI/GUI_Paint.h index 7273ca9..ceeacfd 100644 --- a/RaspberryPi_JetsonNano/c/lib/GUI/GUI_Paint.h +++ b/RaspberryPi_JetsonNano/c/lib/GUI/GUI_Paint.h @@ -202,6 +202,7 @@ void Paint_DrawChar(UWORD Xstart, UWORD Ystart, const char Acsii_Char, sFONT* Fo void Paint_DrawString_EN(UWORD Xstart, UWORD Ystart, const char * pString, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background); void Paint_DrawString_CN(UWORD Xstart, UWORD Ystart, const char * pString, cFONT* font, UWORD Color_Foreground, UWORD Color_Background); void Paint_DrawNum(UWORD Xpoint, UWORD Ypoint, int32_t Nummber, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background); +void Paint_DrawNumDecimals(UWORD Xpoint, UWORD Ypoint, double Nummber, sFONT* Font, UWORD Digit, UWORD Color_Foreground, UWORD Color_Background); // Able to display decimals void Paint_DrawTime(UWORD Xstart, UWORD Ystart, PAINT_TIME *pTime, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background); //pic diff --git a/RaspberryPi_JetsonNano/c/list.txt b/RaspberryPi_JetsonNano/c/list.txt index 88409ea..9627ab1 100644 --- a/RaspberryPi_JetsonNano/c/list.txt +++ b/RaspberryPi_JetsonNano/c/list.txt @@ -15,7 +15,8 @@ EPD model EPD define (EPD=) 2.9inch e-Paper (B)/(C) epd2in9bc 2.9inch e-Paper (B) (V3) epd2in9bV3 2.9inch e-Paper (D) epd2in9d -2.9inch e-Paper (V3) epd2in13V3 +2.13inch e-Paper (V2) epd2in13V2 +2.13inch e-Paper (V3) epd2in13V3 2.13inch e-Paper (B)/(C) epd2in13bc 2.13inch e-Paper (B) (V3) epd2in13bV3 2.13inch e-Paper (B) (V4) epd2in13bV4 diff --git a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd7in5_V2.py b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd7in5_V2.py index b1495ca..8314a4e 100644 --- a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd7in5_V2.py +++ b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd7in5_V2.py @@ -124,7 +124,7 @@ class EPD: def send_data2(self, data): epdconfig.digital_write(self.dc_pin, 1) epdconfig.digital_write(self.cs_pin, 0) - epdconfig.SPI.writebytes2(data) + epdconfig.spi_writebyte2(data) epdconfig.digital_write(self.cs_pin, 1) def ReadBusy(self): diff --git a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd7in5b_V2.py b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd7in5b_V2.py index df09ae3..b69cefa 100644 --- a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd7in5b_V2.py +++ b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd7in5b_V2.py @@ -70,7 +70,7 @@ class EPD: def send_data2(self, data): #faster epdconfig.digital_write(self.dc_pin, 1) epdconfig.digital_write(self.cs_pin, 0) - epdconfig.SPI.writebytes2(data) + epdconfig.spi_writebyte2(data) epdconfig.digital_write(self.cs_pin, 1) def ReadBusy(self): diff --git a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epdconfig.py b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epdconfig.py index 3d22c85..8f8b517 100644 --- a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epdconfig.py +++ b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epdconfig.py @@ -29,7 +29,6 @@ import os import logging -from ossaudiodev import SOUND_MIXER_SPEAKER import sys import time