Skip to content

Commit

Permalink
Fix conio.h and update hello-C demo
Browse files Browse the repository at this point in the history
  • Loading branch information
mesheets committed Jul 20, 2024
1 parent 997bac4 commit 577b0aa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
12 changes: 12 additions & 0 deletions demo/c/hello-C.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,24 @@
#include <unistd.h>

int main(int argc, char **argv) {
// Display a friendly message on the RCX screen
cputc_native_user(CHAR_H, CHAR_E, CHAR_PARALLEL, CHAR_O); // HELLO
sleep(1);
cputc_native_user(CHAR_L, CHAR_E, CHAR_G, CHAR_O); //LEGO
sleep(1);
cls();
sleep(1);

// Use different methods and display the same message upside down
cputc_hex_4(0x00);
cputc_native_3(CHAR_PARALLEL);
cputc_hex(0x03, 2);
cputc_hex(0x04, 1);
sleep(1);
cputw(0x0937);
sleep(1);
cls();
sleep(1);

return 0;
}
9 changes: 6 additions & 3 deletions include/conio.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,6 @@ extern void cputc_native_3(char mask);
extern void cputc_native_4(char mask);
//! write bit-pattern for segments at position 5 of LCD
extern void cputc_native_5(char mask);
//! write bit-pattern for segments in positions 4 through 1 of the LCD (the main user portion)
extern void cputc_native_user(char mask_left, char mask_lcenter, char mask_rcenter, char mask_right);

//! Set/Clear individual segments at specified position of LCD
/*! (this is essentially a dispatcher for cputc_native_[0-5] functions)
Expand All @@ -243,6 +241,10 @@ extern void cputc_native_user(char mask_left, char mask_lcenter, char mask_rcent
*/
extern void cputc_native(char mask, int pos);

//! write bit-pattern for segments in positions 4 through 1 of the LCD (the main user portion)
extern void cputc_native_user(char mask_left, char mask_lcenter, char mask_rcenter, char mask_right);


//! write HEX digit to position 0 of LCD
extern inline void cputc_hex_0(unsigned nibble)
{
Expand Down Expand Up @@ -280,14 +282,15 @@ extern inline void cputc_hex_5(unsigned nibble)
* \param pos the location at which to display the HEX digit
* \return Nothing
*/
extern inline void cputc_hex(char c, int pos)
extern inline void cputc_hex(unsigned nibble, int pos)
{
cputc_native(get_hex_display_code(nibble), pos);
}

//! Write a HEX word to LCD
extern void cputw(unsigned word);


#ifdef CONF_ASCII
//! write ASCII char to position 0 of LCD
extern inline void cputc_0(unsigned c)
Expand Down

0 comments on commit 577b0aa

Please sign in to comment.