changeset 136:7d5b412ffb6c

aci: AT%VBAT and melody play enhancements from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 07 Jan 2019 18:47:52 +0000
parents ac4c0a9bc022
children 6b94853890cf
files src/g23m-aci/aci/aci_cmh.h src/g23m-aci/aci/ati_audio.c src/g23m-aci/aci/ati_cmd.c src/g23m-aci/aci/ati_fchg.c
diffstat 4 files changed, 75 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/g23m-aci/aci/aci_cmh.h	Thu Dec 20 04:24:06 2018 +0000
+++ b/src/g23m-aci/aci/aci_cmh.h	Mon Jan 07 18:47:52 2019 +0000
@@ -529,8 +529,10 @@
   AT_CMD_AT_VPATH,
   AT_CMD_AT_SND,
   AT_CMD_AT_E1,
+  AT_CMD_AT_E1STOP,
   AT_CMD_AT_E2,
   AT_CMD_AT_E2LSI,
+  AT_CMD_AT_E2STOP,
   AT_CMD_AT_TONE,
   AT_CMD_AT_TSTOP,
   AT_CMD_AT_VMP,
@@ -539,6 +541,7 @@
   AT_CMD_AT_VMRS,
   AT_CMD_P_CBC,
   AT_CMD_AT_CHG,
+  AT_CMD_P_VBAT,
   /* terminator */
   AT_CMD_MAX,                  /* maximum command id */
   AT_CMD_BIGGEST = 0x0000ffff  /* To avoid the lint warning 650 */
--- a/src/g23m-aci/aci/ati_audio.c	Thu Dec 20 04:24:06 2018 +0000
+++ b/src/g23m-aci/aci/ati_audio.c	Mon Jan 07 18:47:52 2019 +0000
@@ -214,45 +214,71 @@
 }
 #endif
 
+static char melody_E1_name[AUDIO_PATH_NAME_MAX_SIZE];
+
 /* AT@E1 - play an E1 format melody */
 GLOBAL T_ATI_RSLT atAtE1 ( char *cl, UBYTE srcId )
 {
 	T_AUDIO_MELODY_E1_PARAMETER e1_param;
+	int loopback = 0;
 	T_RV_RETURN return_path;
 
-	cl = parse(cl, "S", (LONG)(sizeof(e1_param.melody_name)),
-		   e1_param.melody_name);
+	cl = parse(cl, "Sd", (LONG)(sizeof(e1_param.melody_name)),
+		   e1_param.melody_name, &loopback);
 	if (!cl || !e1_param.melody_name[0])
 		return (ATI_FAIL);
-	e1_param.loopback = AUDIO_MELODY_NO_LOOPBACK;
+	e1_param.loopback = loopback;
 	e1_param.melody_mode = AUDIO_MELODY_NORMAL_MODE;
 
 	return_path.addr_id        = NULL;
 	return_path.callback_func  = audio_callback;
-	if (audio_melody_E1_start(&e1_param, return_path) == AUDIO_OK)
+	if (audio_melody_E1_start(&e1_param, return_path) == AUDIO_OK) {
+		strcpy(melody_E1_name, e1_param.melody_name);
+		return (ATI_CMPL);
+	} else
+		return (ATI_FAIL);
+}
+
+/* AT@E1STOP - stop melody started with AT@E1 */
+GLOBAL T_ATI_RSLT atAtE1STOP ( char *cl, UBYTE srcId )
+{
+	T_AUDIO_MELODY_E1_STOP_PARAMETER e1stop_param;
+	T_RV_RETURN return_path;
+
+	if (!melody_E1_name[0])
+		return (ATI_FAIL);
+	strcpy(e1stop_param.melody_name, melody_E1_name);
+
+	return_path.addr_id        = NULL;
+	return_path.callback_func  = audio_callback;
+	if (audio_melody_E1_stop(&e1stop_param, return_path) == AUDIO_OK)
 		return (ATI_CMPL);
 	else
 		return (ATI_FAIL);
 }
 
+static char melody_E2_name[AUDIO_PATH_NAME_MAX_SIZE];
+
 /* AT@E2 - play an E2 format melody */
 GLOBAL T_ATI_RSLT atAtE2 ( char *cl, UBYTE srcId )
 {
 	T_AUDIO_MELODY_E2_PARAMETER e2_param;
+	int loopback = 0;
 	T_RV_RETURN return_path;
 
-	cl = parse(cl, "S", (LONG)(sizeof(e2_param.melody_E2_name)),
-		   e2_param.melody_E2_name);
+	cl = parse(cl, "Sd", (LONG)(sizeof(e2_param.melody_E2_name)),
+		   e2_param.melody_E2_name, &loopback);
 	if (!cl || !e2_param.melody_E2_name[0])
 		return (ATI_FAIL);
-	e2_param.E2_loopback = AUDIO_MELODY_NO_LOOPBACK;
+	e2_param.E2_loopback = loopback;
 	e2_param.melody_E2_mode = AUDIO_MELODY_NORMAL_MODE;
 
 	return_path.addr_id        = NULL;
 	return_path.callback_func  = audio_callback;
-	if (audio_melody_E2_start(&e2_param, return_path) == AUDIO_OK)
+	if (audio_melody_E2_start(&e2_param, return_path) == AUDIO_OK) {
+		strcpy(melody_E2_name, e2_param.melody_E2_name);
 		return (ATI_CMPL);
-	else
+	} else
 		return (ATI_FAIL);
 }
 
@@ -272,6 +298,24 @@
 		return (ATI_FAIL);
 }
 
+/* AT@E2STOP - stop melody started with AT@E2 */
+GLOBAL T_ATI_RSLT atAtE2STOP ( char *cl, UBYTE srcId )
+{
+	T_AUDIO_MELODY_E2_STOP_PARAMETER e2stop_param;
+	T_RV_RETURN return_path;
+
+	if (!melody_E2_name[0])
+		return (ATI_FAIL);
+	strcpy(e2stop_param.melody_E2_name, melody_E2_name);
+
+	return_path.addr_id        = NULL;
+	return_path.callback_func  = audio_callback;
+	if (audio_melody_E2_stop(&e2stop_param, return_path) == AUDIO_OK)
+		return (ATI_CMPL);
+	else
+		return (ATI_FAIL);
+}
+
 /* AT@TONE - exercise TONES through RiViera Audio Service API */
 GLOBAL T_ATI_RSLT atAtTONE ( char *cl, UBYTE srcId )
 {
--- a/src/g23m-aci/aci/ati_cmd.c	Thu Dec 20 04:24:06 2018 +0000
+++ b/src/g23m-aci/aci/ati_cmd.c	Mon Jan 07 18:47:52 2019 +0000
@@ -753,8 +753,10 @@
 #endif
 EXTERN T_ATI_RSLT atAtSND (char *cl, UBYTE srcId);
 EXTERN T_ATI_RSLT atAtE1 (char *cl, UBYTE srcId);
+EXTERN T_ATI_RSLT atAtE1STOP (char *cl, UBYTE srcId);
 EXTERN T_ATI_RSLT atAtE2 (char *cl, UBYTE srcId);
 EXTERN T_ATI_RSLT atAtE2LSI (char *cl, UBYTE srcId);
+EXTERN T_ATI_RSLT atAtE2STOP (char *cl, UBYTE srcId);
 EXTERN T_ATI_RSLT atAtTONE (char *cl, UBYTE srcId);
 EXTERN T_ATI_RSLT atAtTSTOP (char *cl, UBYTE srcId);
 EXTERN T_ATI_RSLT atAtVMP (char *cl, UBYTE srcId);
@@ -765,6 +767,7 @@
 EXTERN T_ATI_RSLT atPercentCBC (char *cl, UBYTE srcId);
 EXTERN T_ATI_RSLT atAtCHG (char *cl, UBYTE srcId);
 #endif
+EXTERN T_ATI_RSLT atPercentVBAT (char *cl, UBYTE srcId);
 
 LOCAL const ATCommand_bas cmds_bas[] =
 {
@@ -1212,8 +1215,10 @@
 #endif
     {"@SND",	AT_CMD_AT_SND,   atAtSND,	0,	0,	0},
     {"@E1",	AT_CMD_AT_E1,    atAtE1,	0,	0,	0},
+    {"@E1STOP",	AT_CMD_AT_E1STOP,atAtE1STOP,	0,	0,	0},
     {"@E2",	AT_CMD_AT_E2,    atAtE2,	0,	0,	0},
     {"@E2LSI",	AT_CMD_AT_E2LSI, atAtE2LSI,	0,	0,	0},
+    {"@E2STOP",	AT_CMD_AT_E2STOP,atAtE2STOP,	0,	0,	0},
     {"@TONE",	AT_CMD_AT_TONE,  atAtTONE,	0,	0,	0},
     {"@TSTOP",	AT_CMD_AT_TSTOP, atAtTSTOP,	0,	0,	0},
     {"@VMP",	AT_CMD_AT_VMP,   atAtVMP,	0,	0,	0},
@@ -1224,6 +1229,7 @@
     {"%CBC",	AT_CMD_P_CBC,    atPercentCBC,	0,	0,	0},
     {"@CHG",	AT_CMD_AT_CHG,   atAtCHG,	test_gen, 0,	"%s: (0,1)"},
 #endif
+    {"%VBAT",	AT_CMD_P_VBAT,   atPercentVBAT,	0,	0,	0},
     /* terminator */
     {NULL,AT_CMD_NONE,NULL,NULL,NULL,NULL}
 };
--- a/src/g23m-aci/aci/ati_fchg.c	Thu Dec 20 04:24:06 2018 +0000
+++ b/src/g23m-aci/aci/ati_fchg.c	Mon Jan 07 18:47:52 2019 +0000
@@ -93,4 +93,17 @@
 
 #endif /* RVM_FCHG_SWE */
 
+/* AT%VBAT - retrieve VBAT measurement, independent of FCHG */
+GLOBAL T_ATI_RSLT atPercentVBAT ( char *cl, UBYTE srcId )
+{
+	extern USHORT *csf_return_adc(void);
+	USHORT *adc_conversion;
+
+	TRACE_FUNCTION("atPercentVBAT()");
+	adc_conversion = csf_return_adc();
+	sprintf(g_sa, "%%VBAT: %u", adc_conversion[0]);
+	io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
+	return ATI_CMPL;
+}
+
 #endif /* ATI_FCHG_C */