-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
432 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bin/ | ||
obj/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"configurations": [{ | ||
"name": "TI84", | ||
"includePath": [ | ||
"${CEDEV}/include" | ||
], | ||
"browse": { | ||
"path": ["${CEDEV}/include"], | ||
"limitSymbolsToIncludedHeaders": true | ||
}, | ||
"cStandard": "c89", | ||
"compilerPath": "${CEDEV}/bin/ez80cc.exe" | ||
|
||
}], | ||
"version": 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"files.associations": { | ||
"*.pyx": "python", | ||
"stdint.h": "c", | ||
"stdio.h": "c", | ||
"tice.h": "c", | ||
"stddef.h": "c", | ||
"stdlib.h": "c", | ||
"conv.h": "c" | ||
}, | ||
|
||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# ---------------------------- | ||
|
||
NAME ?= Binary | ||
COMPRESSED ?= YES | ||
ICON ?= images/icon.png | ||
DESCRIPTION ?= "Binary Converter and Addition" | ||
|
||
# ---------------------------- | ||
|
||
include $(CEDEV)/include/.makefile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# ti84ce-binary | ||
|
||
A program written in C for the TI-84 Plus CE Calculator that converts between decimal and 8-bit signed (two's complement) binary | ||
|
||
## Main Menu | ||
|
||
![](images/menu.png) | ||
|
||
## Decimal To Binary | ||
|
||
![](images/1.png) | ||
|
||
## Binary to Decimal | ||
|
||
![](images/2.png) | ||
|
||
## Binary Addition | ||
|
||
![](images/3.png) | ||
|
||
|
||
## Build Instructions | ||
|
||
1. Install the TI-84 Plus CE toolchain from https://github.com/CE-Programming/toolchain/releases | ||
|
||
2. Make sure the `CEDEV` environment variable is set and the `bin` folder of the toolchain is on the PATH | ||
|
||
3. From the commandline, run `make` | ||
|
||
4. The generated program will be in `bin/Binary.8xp` | ||
|
||
5. Use [TI Connect CE](https://education.ti.com/en/products/computer-software/ti-connect-ce-sw) or a similar program to move the file to your calculator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#ifndef CONV_H | ||
#define CONV_H | ||
|
||
#include <tice.h> | ||
|
||
void print_int(int8_t x) | ||
{ | ||
char str[5]; | ||
real_t real; | ||
|
||
real = os_Int24ToReal(x); | ||
os_RealToStr(str, &real, -1, 0, -1); | ||
os_PutStrLine(str); | ||
} | ||
|
||
void print_binary(int8_t x) | ||
{ | ||
int i; | ||
char str[9]; | ||
|
||
for (i = 7; i >= 0; i--) { | ||
str[i] = (x & 1) + '0'; | ||
x >>= 1; | ||
} | ||
str[8] = '\0'; | ||
|
||
os_PutStrLine(str); | ||
} | ||
|
||
void print_numkey(sk_key_t key) | ||
{ | ||
switch (key) { | ||
case sk_0: | ||
os_PutStrLine("0"); | ||
break; | ||
case sk_1: | ||
os_PutStrLine("1"); | ||
break; | ||
case sk_2: | ||
os_PutStrLine("2"); | ||
break; | ||
case sk_3: | ||
os_PutStrLine("3"); | ||
break; | ||
case sk_4: | ||
os_PutStrLine("4"); | ||
break; | ||
case sk_5: | ||
os_PutStrLine("5"); | ||
break; | ||
case sk_6: | ||
os_PutStrLine("6"); | ||
break; | ||
case sk_7: | ||
os_PutStrLine("7"); | ||
break; | ||
case sk_8: | ||
os_PutStrLine("8"); | ||
break; | ||
case sk_9: | ||
os_PutStrLine("9"); | ||
break; | ||
} | ||
} | ||
|
||
int key_to_int(sk_key_t key) | ||
{ | ||
switch (key) { | ||
case sk_0: | ||
return 0; | ||
case sk_1: | ||
return 1; | ||
case sk_2: | ||
return 2; | ||
case sk_3: | ||
return 3; | ||
case sk_4: | ||
return 4; | ||
case sk_5: | ||
return 5; | ||
case sk_6: | ||
return 6; | ||
case sk_7: | ||
return 7; | ||
case sk_8: | ||
return 8; | ||
case sk_9: | ||
return 9; | ||
default: | ||
return 0; | ||
} | ||
} | ||
|
||
#endif /* CONV_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
#ifndef IO_H | ||
#define IO_H | ||
|
||
#include "conv.h" | ||
#include <tice.h> | ||
|
||
#define clear() os_ClrHome() | ||
#define setpos(row, col) os_SetCursorPos(row, col) | ||
#define print(text) os_PutStrLine(text) | ||
#define print_at(text, row, col) \ | ||
os_SetCursorPos(row, col); \ | ||
os_PutStrLine(text) | ||
#define wait() while (!os_GetCSC()) | ||
|
||
void update_select(int8_t* selection, int8_t after) | ||
{ | ||
print_at(" ", 2 + *selection, 2); | ||
|
||
if (after > 3) { | ||
*selection = 1; | ||
} else if (after < 1) { | ||
*selection = 3; | ||
} else { | ||
*selection = after; | ||
} | ||
|
||
print_at(">", 2 + *selection, 2); | ||
} | ||
|
||
void print_box() | ||
{ | ||
int i; | ||
print_at("-----------------------", 2, 2); | ||
for (i = 3; i < 8; i++) { | ||
print_at("| |", i, 2); | ||
} | ||
print_at("-----------------------", 8, 2); | ||
} | ||
|
||
uint8_t binary_input() | ||
{ | ||
unsigned int startRow, startCol; | ||
uint8_t current = 0; | ||
uint8_t out = 0; | ||
|
||
sk_key_t key; | ||
|
||
os_GetCursorPos(&startRow, &startCol); | ||
os_EnableCursor(); | ||
|
||
while (true) { | ||
key = os_GetCSC(); | ||
|
||
if (key == sk_Enter) { | ||
os_DisableCursor(); | ||
setpos(startRow, startCol); | ||
print_binary(out); | ||
return out; | ||
} else if (key == sk_Clear) { | ||
out = 0; | ||
current = 0; | ||
print_at(" ", startRow, startCol); | ||
setpos(startRow, startCol); | ||
} else if (current < 8 && (key == sk_0 || key == sk_1)) { | ||
print_numkey(key); | ||
out <<= 1; | ||
out += key_to_int(key); | ||
current++; | ||
} | ||
} | ||
} | ||
|
||
int8_t decimal_input() | ||
{ | ||
unsigned int startRow, startCol; | ||
uint8_t current = 0; | ||
int8_t out = 0; | ||
bool isNeg = false; | ||
sk_key_t key; | ||
|
||
os_GetCursorPos(&startRow, &startCol); | ||
os_EnableCursor(); | ||
|
||
while (true) { | ||
key = os_GetCSC(); | ||
|
||
if (key == sk_Enter) { | ||
os_DisableCursor(); | ||
if (isNeg) { | ||
return -out; | ||
} | ||
return out; | ||
} else if (key == sk_Clear) { | ||
out = 0; | ||
current = 0; | ||
isNeg = false; | ||
print_at(" ", startRow, startCol); | ||
setpos(startRow, startCol); | ||
} else if (key == sk_Sub || key == sk_Chs) { | ||
if (current == 0) { /* only allow negatives at beginning of number */ | ||
isNeg = true; | ||
print("-"); | ||
} | ||
} else if (key == sk_0 | ||
|| key == sk_1 | ||
|| key == sk_2 | ||
|| key == sk_3 | ||
|| key == sk_4 | ||
|| key == sk_5 | ||
|| key == sk_6 | ||
|| key == sk_7 | ||
|| key == sk_8 | ||
|| key == sk_9) { | ||
|
||
if (current < 3) { | ||
print_numkey(key); | ||
out *= 10; | ||
out += key_to_int(key); | ||
current++; | ||
} | ||
} | ||
} | ||
} | ||
|
||
#endif /* IO_H */ |
Oops, something went wrong.