That is GCBASIC Stan, have you never used the Logic Shift Functions?
fnLSL() is Logic shift left the equivalent of the << operator in C.
fnLSR() is Logic Shift Right and is the same as the >> operator.
They are very useful tools when working with Logic manipulation or Maths.
A left shift is equivalent to a binary division and a right shift is a useful multiplication.
Have a look in the help.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I 've used them, dunno if rotating left or right is faster than *2 or /2.
Very useful functions with the carry and stuff.
I just had "fun" day using linux...not really :)
I put an os on a usb for rpi and now the stick is bricked. :)
oh um
Nice you helped someone.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm using an AHT20 Temperature/Humidity sensor. See page 8 of
https://cdn.sparkfun.com/assets/d/2/b/e/d/AHT20.pdf
The temperature section is working but I get humidity values greater than 100%.
I found this code for the humidity calculation on a web site.
/* Extract 20-bits of humidity data */
uint32_t reg_humidity = regs[1];
reg_humidity <<= 8;
reg_humidity |= regs[2];
reg_humidity <<= 4;
reg_humidity |= (regs[3] >> 4);
*humidity = (reg_humidity / 1048576.0);
Can anyone translate this into GCB?
Is it assummed that regs[x] are 32 bit numbers? or, what sort of number does reg[x] represent?
uint32_t reg_humidity = reg[1]
translates as
Dim reg_humidity long
reg_humidity = regs[1]
reg_humidity <<=8
translates as
reg_humidity = fnLSL(reg_humidity, 8)
reg_humidity |= regs[2]
translates as
reg_humidity = reg_humidity OR regs[2]
reg_humidity <<= 4
translates as
reg_humidity = fnLSL(reg_humidity, 4)
reg_humidity |= (regs[3] >> 4)
translates as
reg_humidity = reg_humidity OR fnLSR(regs[3], 4)
humidity = reg_humidity / 1048576
You give no indication of the origin and composition of the regs() array but the above should point you in the right direction.
Last edit: Chris Roper 2021-01-11
Thanks Chris....what's that in gcb? :)
That is GCBASIC Stan, have you never used the Logic Shift Functions?
fnLSL() is Logic shift left the equivalent of the << operator in C.
fnLSR() is Logic Shift Right and is the same as the >> operator.
They are very useful tools when working with Logic manipulation or Maths.
A left shift is equivalent to a binary division and a right shift is a useful multiplication.
Have a look in the help.
Thanks to all for your help!
Let us know if it works.
I would love to put this in the help!
I 've used them, dunno if rotating left or right is faster than *2 or /2.
Very useful functions with the carry and stuff.
I just had "fun" day using linux...not really :)
I put an os on a usb for rpi and now the stick is bricked. :)
oh um
Nice you helped someone.