changeset 565:96c1d047b3c6

aci2: AT%VBAT and melody play enhancements matching aci3
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 07 Jan 2019 01:06:46 +0000
parents ade27cd84b97
children f6f599aad453
files src/aci2/aci/aci_cmh.h src/aci2/aci/ati_audio.c src/aci2/aci/ati_cmd.c src/aci2/aci/ati_fchg.c
diffstat 4 files changed, 75 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/aci2/aci/aci_cmh.h	Mon Jan 07 00:47:48 2019 +0000
+++ b/src/aci2/aci/aci_cmh.h	Mon Jan 07 01:06:46 2019 +0000
@@ -483,8 +483,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,
@@ -493,6 +495,7 @@
   AT_CMD_AT_VMRS,
   AT_CMD_P_CBC,
   AT_CMD_AT_CHG,
+  AT_CMD_P_VBAT,
   /* terminator */
   AT_CMD_MAX                  /* maximum command id */
 } T_ACI_AT_CMD;
--- a/src/aci2/aci/ati_audio.c	Mon Jan 07 00:47:48 2019 +0000
+++ b/src/aci2/aci/ati_audio.c	Mon Jan 07 01:06:46 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/aci2/aci/ati_cmd.c	Mon Jan 07 00:47:48 2019 +0000
+++ b/src/aci2/aci/ati_cmd.c	Mon Jan 07 01:06:46 2019 +0000
@@ -685,8 +685,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);
@@ -697,6 +699,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[] =
 {
@@ -1093,8 +1096,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},
@@ -1105,6 +1110,7 @@
     {"%CBC",	AT_CMD_P_CBC,    atPercentCBC,	0,	0,	0},
     {"@CHG",	AT_CMD_AT_CHG,   atAtCHG,	0,	0,	"%s: (0,1)"},
 #endif
+    {"%VBAT",	AT_CMD_P_VBAT,   atPercentVBAT,	0,	0,	0},
     /* terminator */
     {NULL,0,0,0,0,0}
 };
--- a/src/aci2/aci/ati_fchg.c	Mon Jan 07 00:47:48 2019 +0000
+++ b/src/aci2/aci/ati_fchg.c	Mon Jan 07 01:06:46 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 */