mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-07-26 10:38:41 +00:00
f57b5ecee9
sharpmem: add implementation of sharpmem display driver * Implement Configure, Clear and ClearBuffer, add some tests, add documentation/comments * Reverse white * Inverted bits, fix and improve ClearBuffer, cleanup * Refine doc comment * Driver refactor, optimizations toggle, additional tests & support for all SKUs * Fix address overflow padding, add wire-level tests for assumed address encoding * Minor rename * Cleanup and doc fixes * Add device configs * Bounds check * Add example and smoketest entry * Use uf2 output file format * Refine example
31 lines
715 B
Go
31 lines
715 B
Go
package sharpmem
|
|
|
|
// setBit sets the bit at pos in n to 1 and returns the updated number.
|
|
func setBit(n uint8, pos uint8) uint8 {
|
|
n |= 1 << pos
|
|
return n
|
|
}
|
|
|
|
// unsetBit sets the bit at pos in n to 0 and returns the updated number.
|
|
func unsetBit(n uint8, pos uint8) uint8 {
|
|
n &^= 1 << pos
|
|
return n
|
|
}
|
|
|
|
// hasBit returns whether the bit at pos in n is 1.
|
|
func hasBit(n uint8, pos uint8) bool {
|
|
n = n & (1 << pos)
|
|
return n > 0
|
|
}
|
|
|
|
// bitfieldBufLen returns the required buffer size for keeping track of
|
|
// changed lines.
|
|
func bitfieldBufLen(bits int16) int16 {
|
|
return 1 + (bits-1)/8
|
|
}
|
|
|
|
// ceilDiv divides a with b, but it uses the ceiling if modulo is not 0.
|
|
func ceilDiv(a, b int16) int16 {
|
|
return 1 + (a-1)/b
|
|
}
|