Skip to content

Commit bd88c72

Browse files
committed
Change gg_init to gg_start. added GG_printf.ino.
1 parent 5e59339 commit bd88c72

File tree

9 files changed

+51
-45
lines changed

9 files changed

+51
-45
lines changed

README.md

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,17 @@ After creating the function of the original command, register it as shown in the
3030

3131
## Functions
3232

33-
|GG_for_Arduino.h|function|
34-
|--|---|
35-
|int gg_init(void)|Initialization of GG for Arduino|
36-
|int gg_tp1_no|Arduino output pin number for TP1. Set before gg_init() if necessary|
37-
|int gg_tp2_no|Arduino output pin number for TP2. Set before gg_init() if necessary|
38-
|long gg_con_baud|baud rate. Set before gg_init() if necessary|
39-
40-
|gg_base.h|function|
33+
|Functions / Variables|Specification|
4134
|--|---|
35+
|***GG_for_Arduino.h***||
36+
|int gg_start(const char \*title)|Start processing GG for Arduino|
37+
|int gg_tp1_no|Arduino output pin number for TP1. Set before gg_start() if necessary|
38+
|int gg_tp2_no|Arduino output pin number for TP2. Set before gg_start() if necessary|
39+
|long gg_con_baud|baud rate. Set before gg_start() if necessary|
40+
|***gg_base.h***||
4241
|GG_TP_ON(number)|Turn on the TP status number|
4342
|GG_TP_OFF(number)|Turn off the TP status number|
44-
45-
|gg_uty.h|function|
46-
|--|---|
47-
|int gg_init(void)|Initialization of GG for Arduino|
48-
|int gg_tp1_no|Arduino output pin number for TP1. Set before gg_init() if necessary|
49-
|int gg_tp2_no|Arduino output pin number for TP2. Set before gg_init() if necessary|
50-
|long gg_con_baud|baud rate. Set before gg_init() if necessary|
43+
|***gg_uty.h***||
5144
|GG_TP_ON(number)|Turn on the TP status number|
5245
|GG_TP_OFF(number)|Turn off the TP status number|
5346
|int gg_GetC(void)|1 character input (-1 = no input)|
@@ -70,28 +63,24 @@ After creating the function of the original command, register it as shown in the
7063
|int gg_tim_checkdt(GGT_TIME \*t)|Date and time validity check|
7164
|int gg_tim_repairdt(GGT_TIME \*t)|Date and time correction|
7265
|int gg_tim_tt2week(gg_time_t x)|Determine what day of the week from gg_time_t(0=sun,..)|
73-
74-
|gg_printf.h|function|
75-
|--|---|
76-
|int gg_vxprintf(int (*putc)(int), const char *fmt, va_list vlst)|vprintf() with putc()|
77-
|int gg_xprintf(int (*putc)(int), const char *fmt, ...)|printf() with putc()|
78-
|int gg_printf(const char *fmt, ...)|printf() with standard output|
79-
|int gg_vsprintf(char *buf, const char *fmt, va_list vlst)|vsprintf() to buf[]|
80-
|int gg_sprintf(char *buf, const char *fmt, ...)|sprintf() to buf[]|
66+
|***gg_printf.h***||
67+
|int gg_vxprintf(int (\*putc)(int), const char \*fmt, va_list vlst)|vprintf() with putc()|
68+
|int gg_xprintf(int (\*putc)(int), const char \*fmt, ...)|printf() with putc()|
69+
|int gg_printf(const char \*fmt, ...)|printf() with standard output|
70+
|int gg_vsprintf(char \*buf, const char \*fmt, va_list vlst)|vsprintf() to buf[]|
71+
|int gg_sprintf(char \*buf, const char \*fmt, ...)|sprintf() to buf[]|
8172
|gg_printDATE(gg_time_t)|"YY/MM/DD"|
8273
|gg_printTIME(gg_time_t)|"hh:mm:ss"|
8374
|gg_printDT(gg_time_t)|"YY/MM/DD hh:mm:ss"|
8475
|gg_printDTs(gg_time_t)|"YY/MM/DD hh:mm:ss "|
85-
86-
|gg_console.h|function|
87-
|--|---|
76+
|***gg_console.h***||
8877
|GG_CON_CMDADD(func, cmd, prm, help)|Registering console commands|
8978
|GG_CON_CMDMRK(title)|Display delimiter of list in help|
9079
|GG_CON|Work area for console (internal use)|
9180
|int gg_con_MonInit(void)|Console initialization|
81+
|char \*gg_con_prompt|Prompt string|
9282
|int gg_con_MonRePrompt(void)|Redisplay prompt|
9383
|int gg_con_MonPrompt(void)|Prompt display (used internally)|
94-
|int gg_con_MonStart(void)|Console start (title)|
9584
|int gg_con_Check(void)|Console check with gg_GetC()|
9685
|int gg_con_MonCheck(int c)|Console check with 1 character|
9786
|int gg_con_MonExec(char \*buf)|Command line processing (Note: buf is destroyed by arg analysis)|

examples/GG_console/GG_console.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
void setup() {
10-
gg_init(); // initialization
10+
gg_start("** GG **\n>"); // Start processing GG for Arduino
1111
}
1212

1313
void loop() {

examples/GG_console_cmd/GG_console_cmd.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
*/
3737

3838
void setup() {
39-
gg_init(); // initialization
39+
gg_start("** GG **\n>"); // Start processing GG for Arduino
4040

4141
// Register with console command (you can add more and more in this way)
4242
GG_CON_CMDMRK("-- Example of original command registration --"); // Delimited line (displayed in the command list)

examples/GG_printf/GG_printf.ino

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <GG_for_Arduino.h>
2+
3+
/*
4+
GG for Arduino ** Printf() demo
5+
Arduino standard serial (115200bps / 8bit length / non-parity)
6+
No command line interface
7+
*/
8+
9+
void setup() {
10+
gg_start("** GG start\n"); // Start processing GG for Arduino
11+
gg_printf("[setup] millis()=%8ld\n", millis());
12+
}
13+
14+
void loop() {
15+
static unsigned char c = 0;
16+
gg_printf("[loop] millis()=%8ld\n", millis());
17+
c++;
18+
gg_printf("c=%3d=0x%02X=0b%08b\n", c, c, c);
19+
gg_printf("delay(1000)\n");
20+
delay(1000);
21+
}

examples/GG_tp/GG_tp.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
void setup() {
1919
gg_tp1_no = 2; // Arduino pin number for TP1
2020
gg_tp2_no = 3; // Arduino pin number for TP2
21-
gg_init(); // initialization
21+
gg_start("** GG **\n>"); // Start processing GG for Arduino
2222
}
2323

2424
void loop() {

src/GG_for_Arduino.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
int gg_DI_count; // 割込み禁止ネスト数(0=割込み許可中)
1212
int gg_tp1_no = -1; // TP1出力ピン番号(-1=なし)
1313
int gg_tp2_no = -1; // TP2出力ピン番号(-1=なし)
14-
long gg_con_baud = 115200; // コンソール用シリアル(Serial)のボーレート(-1=gg_init()で初期化しない)
14+
long gg_con_baud = 115200; // コンソール用シリアル(Serial)のボーレート(-1=gg_start()で初期化しない)
1515

1616
static int std_putc_sub(int c)
1717
{
@@ -28,7 +28,7 @@ static int std_getc()
2828
return Serial.read();
2929
}
3030

31-
int gg_init(void) // Arduino用GGツール初期化
31+
int gg_start(const char *title) // Arduino用GGの処理開始
3232
{
3333
// TP出力の初期化(セットされてれば出力に初期化)
3434
if (gg_tp1_no>=0) pinMode(gg_tp1_no, OUTPUT);
@@ -45,7 +45,9 @@ int gg_init(void) // Arduino用GGツール初期化
4545
ggbase_init(); // GGツール初期化
4646
gg_con_MonInit(); // GGモニタ初期化
4747
gg_con_RegistCMD(); // 標準コマンド登録
48-
gg_con_MonStart(); // GGモニタ開始(タイトルとプロンプト表示)
48+
49+
// デバッグモニタ開始(タイトル表示) 旧:gg_con_MonStart()
50+
if (title) gg_PutS(title);
4951

5052
return 0;
5153
}

src/GG_for_Arduino.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010

1111
#include "ggbase.h"
1212

13-
// gg_init()時の変更可能パラメータ(事前にデフォルト値が入っている)(Arduino専用)
13+
// gg_start()時の変更可能パラメータ(事前にデフォルト値が入っている)(Arduino専用)
1414
extern int gg_tp1_no; // TP1出力ピン番号(-1=なし)
1515
extern int gg_tp2_no; // TP2出力ピン番号(-1=なし)
16-
extern long gg_con_baud; // コンソール用シリアル(Serial)のボーレート(負数ならgg_init()で初期化しない)
16+
extern long gg_con_baud; // コンソール用シリアル(Serial)のボーレート(負数ならgg_start()で初期化しない)
1717

18-
int gg_init(void); // Arduino用GGツール初期化
18+
int gg_start(const char *title); // Arduino用GGの処理開始
1919

2020

2121
#endif // __GG_FOR_ARDUINO_H__

src/gg_console.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ int gg_con_MonInit(void) // デバッグモニタ初期化
2323
return 0;
2424
}
2525

26+
char *gg_con_prompt = ">"; // プロンプト文字列 2022.05.24 M.Kogan
2627
int gg_con_MonRePrompt(void) // プロンプト再表示
2728
{
2829
int i;
29-
gg_PutC('>'); // プロンプト
30+
if (gg_con_prompt) gg_PutS(gg_con_prompt); // プロンプト
3031
for (i=0; i<GG_CON.BufP; i++) {
3132
gg_PutC(GG_CON.Buf[i]);
3233
}
@@ -39,13 +40,6 @@ int gg_con_MonPrompt(void) // プロンプト表示(内部で使用)
3940
return gg_con_MonRePrompt();
4041
}
4142

42-
int gg_con_MonStart(void) // デバッグモニタ開始(タイトル表示)
43-
{
44-
gg_PutS("** GG console\n");
45-
gg_con_MonPrompt(); // バッファクリアとプロンプト表示
46-
return 0;
47-
}
48-
4943
int gg_con_Check(void) // デバッグモニタチェック(0=実行無か実行成功,-999=EXIT要請)(gg_GetC()から1文字受付)
5044
{
5145
return gg_con_MonCheck(gg_GetC()); // gg_GetC()から1文字受付

src/gg_console.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ extern GGT_CON GG_CON; // GG_CONワーク(gg_console.c)
7272
//
7373
#define GG_CON_EXIT (-999) // EXITコード
7474
int gg_con_MonInit(void); // デバッグモニタ初期化
75+
extern char *gg_con_prompt; // プロンプト文字列
7576
int gg_con_MonRePrompt(void); // プロンプト再表示
7677
int gg_con_MonPrompt(void); // プロンプト表示(内部で使用)
77-
int gg_con_MonStart(void); // デバッグモニタ開始(タイトル表示)
7878
int gg_con_Check(void); // デバッグモニタチェック(0=実行無か実行成功,-999=EXIT要請)(gg_GetC()から1文字受付)
7979
int gg_con_MonCheck(int c); // デバッグモニタチェック(0=実行無か実行成功,-999=EXIT要請)(1文字受付)
8080

0 commit comments

Comments
 (0)