Added ulong2uchar (version 3.5).

This commit is contained in:
Gerhard Hoffmann 2023-04-18 13:39:52 +02:00
parent 87a6ed0795
commit c85b090306
2 changed files with 20 additions and 0 deletions

View File

@ -13,6 +13,9 @@ uint32_t uchar2ulong(uint8_t Highbyte, uint8_t MHbyte, uint8_t MLbyte, uint8_t L
uint8_t uint2uchar(uint16_t uival, bool getHighB); uint8_t uint2uchar(uint16_t uival, bool getHighB);
uint8_t ulong2uchar(uint32_t ulval, uint8_t getBytNr);
// getBytNr: 0=LSB 3=MSB
void delay(uint16_t MilliSec); void delay(uint16_t MilliSec);

View File

@ -76,6 +76,23 @@ uint8_t uint2uchar(uint16_t uival, bool getHighB)
} }
uint8_t ulong2uchar(uint32_t ulval, uint8_t getBytNr)
{
// getBytNr: 0=LSB 3=MSB
uint32_t ultmp=ulval;
if (getBytNr==0)
return uint8_t(ultmp);
ultmp>>=8;
if (getBytNr==1)
return uint8_t(ultmp);
ultmp>>=8;
if (getBytNr==2)
return uint8_t(ultmp);
ultmp>>=8;
return uint8_t(ultmp);
}
void delay(uint16_t MilliSec) void delay(uint16_t MilliSec)
{ {
QThread::msleep(uint32_t(MilliSec)); QThread::msleep(uint32_t(MilliSec));