annotate target-utils/buzplayer/melentry.c @ 752:c79aaed75bd8

compile-fc-batt: allow possible third field in source lines Battery tables maintained in the fc-battery-conf repository will now have a third field added, defining thresholds for the battery bars icon, and there will be a new utility to compile them into the new /etc/batterytab2 file read by the FC Tourmaline version of our FCHG driver. For backward compatibility with the original Magnetite version of FCHG, compile-fc-batt remains the tool for compiling the original /etc/batterytab file format, and it needs to ignore the newly added third field in battery table sources.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 05 Nov 2020 20:37:55 +0000
parents eb5960dc258c
children 9092ff68e37d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
80
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 #include <sys/types.h>
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 #include <ctype.h>
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 #include <stdlib.h>
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 #include "types.h"
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include "melody.h"
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 extern struct melentry *melody_buf_start, *melody_buf_tailptr;
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 void
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 melody_init()
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 {
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 melody_buf_tailptr = melody_buf_start;
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 }
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 void
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 melody_entry(argbulk)
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 char *argbulk;
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 {
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 char *argv[3];
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 u32 tone, dur;
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 if (parse_args(argbulk, 2, 2, argv, 0) < 0)
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 return;
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 tone = strtoul(argv[0], 0, 0);
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 dur = strtoul(argv[1], 0, 0);
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 if (tone > 255 || dur < 1 || dur > 0xFFFF) {
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 printf("ERROR: argument(s) out of range\n");
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 return;
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 }
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 melody_buf_tailptr->tone = tone;
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 melody_buf_tailptr->dur = dur;
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 melody_buf_tailptr++;
eb5960dc258c buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 }