参考
[Prog] 整数を10進数で表現した文字列への変換
いろいろ注意
- 過去ログを見よ!!!
- U(S)ART support:"Disabled(no Serial support)"
- 容量不足で、いろんな物が、同時に動かない。
- いろいろ、stm32の方が数てきには、売れているが人気がない。esp32の方が人気がある。特にs3のやつ。やつ(s3)が、最低限かも!!!
- いろいろ、ベンチの結果も、s3が最高て、書いてあった。(何の話し?(RP2350も
結果
プログラム
//AQM0802A_8951_C011_5
//インクルド
//#include <Arduino.h>
#include <Wire.h> //I2C library
//定義
//i2cバッファー
char data_read[2]; // = { 0x00, 0x00 };
//初期レジスター
char INIT_com[] = {
0x0, 0x38, //1
0x0, 0x39, //2
0x0, 0x4, //3
0x0, 0x14, //4
0x0, 0x70, //5
0x0, 0x56, //6
0x0, 0x6C, //7
0x0, 0x38, //8
0x0, 0xC //9
};
//画面のクリアレジスター
char INIT_cls[] = { 0x0, 0x1 };
//i2c書き込みルーチン
void i2c_lcd_w(char *buff1) {
Wire.beginTransmission(0x3E);
Wire.write(buff1[0]);
Wire.write(buff1[1]);
Wire.endTransmission();
delay(2);
} //i2c_lcd_w
//I2Cに一文字を出力
void ns_putc(char ch) {
data_read[0] = '@'; //データ
data_read[1] = ch; //文字
//I2Cに送信
i2c_lcd_w(data_read);
} //ns_putc
//I2Cに文字列を出力
void ns_puts(const char *str1) {
//文字の中身がゼロか
while (*str1) {
//一文字出力
ns_putc(*str1++);
} //while
} //ns_puts
//カーソルの移動
void setCursor(int col, int rows) {
data_read[0] = 0x00; //コマンド
data_read[1] = 0x80 | (rows * 0x40) | col; //カーソルを移動
//I2Cに送信
i2c_lcd_w(data_read);
} //setCursor
//初期化関数
void setup() {
//I2Cのポートの変更
//Wire.setSDA(19); //PA10
//Wire.setSCL(18); //PA9
//I2Cの初期化
Wire.begin();
//液晶の初期化
for (int ii = 0; ii < 9; ii++) {
i2c_lcd_w(&INIT_com[ii << 1]); // ii << 1 = ii * 2
} //for
//画面のクリア
i2c_lcd_w(INIT_cls);
//表示 debug
//setCursor(0, 0); ns_puts("HELLO");
//setCursor(0, 1); ns_puts("WORLD");
//delay(1000); // Wait 1 seconds for next
} //setup
//メインループ
void loop() {
//画面のクリア
//i2c_lcd_w(INIT_cls);
int Voltage = 8951; //電圧
//変換。
char str1[] = "00.00";
int n = Voltage; //変換元
int a; //一時変数
a = (n * 52429) >> 19; // n / 10;
str1[4] = '0' + n - (a * 10);
n = a;
a = (n * 52429) >> 19; // n / 10;
str1[3] = '0' + n - (a * 10);
n = a;
a = (n * 52429) >> 19; // n / 10;
str1[1] = '0' + n - (a * 10);
n = a;
a = (n * 52429) >> 19; // n / 10;
str1[0] = '0' + n - (a * 10);
//n = a;
//表示
setCursor(0, 0); ns_puts(str1);
delay(1000); // Wait 1 seconds for next
} //loop