From eed873b91888e3618e8aadd30859d318cc45b559 Mon Sep 17 00:00:00 2001 From: Jakub Wilk Date: Mon, 3 Apr 2023 22:44:28 +0200 Subject: [PATCH] Compute NSCALES automatically --- scales.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/scales.h b/scales.h index 6469601..603ca52 100644 --- a/scales.h +++ b/scales.h @@ -9,11 +9,6 @@ // #include -// -// **NSCALES** should be kept updated with the length of the list. -// -#define NSCALES 13 - // // What is the number of the weighing result to show, as the first result may be incorrect (from the previous weighing) // @@ -23,7 +18,7 @@ // Scales // ------ // -uint16_t scales[NSCALES][2] = {\ +uint16_t scales[][2] = {\ // Stamps.com Model 510 5LB Scale {0x1446, 0x6a73}, // USPS (Elane) PS311 "XM Elane Elane UParcel 30lb" @@ -52,3 +47,5 @@ uint16_t scales[NSCALES][2] = {\ // mine did at first but now it's behaving itself {0x1446, 0x6a79} }; + +#define NSCALES ((sizeof scales)/(sizeof scales[0]))