# HG changeset patch
# User nicolas jon pike <nicolas.jon.pike@gmail.com>
# Date 1520522545 0
#      Thu Mar 08 15:22:25 2018 +0000
# Node ID a1aea388f973ee1fbae46ae63839e357c71b59c8
# Parent  8339092e358082d4c1471283403bfaa3f73c05fc
FT70 driver New Model #5329
I now have enough of the driver working to be useful.
Read / write memories, a number of the settings, and import from RepeaterBook work.
Saving modes dn,vw and AMS in memory channels, do not currently work.
Banks have not been tested - may now work, VFO settings not implemented (etc)

diff -r 8339092e3580 -r a1aea388f973 .DS_Store
Binary file .DS_Store has changed
diff -r 8339092e3580 -r a1aea388f973 chirp/.DS_Store
Binary file chirp/.DS_Store has changed
diff -r 8339092e3580 -r a1aea388f973 chirp/drivers/ft70.py
--- a/chirp/drivers/ft70.py	Sat Feb 17 17:33:30 2018 +0000
+++ b/chirp/drivers/ft70.py	Thu Mar 08 15:22:25 2018 +0000
@@ -14,8 +14,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-import re
-import string
 import logging
 
 from chirp.drivers import yaesu_clone
@@ -54,10 +52,12 @@
 // rf.memory_bounds = (1, 900) - should this be 0? as zero displays as blank
 // RPT offsets (stored per band) not included.
 // 59 Display radio firmware version info and Radio ID?
-// Display and AMS memory tags?
 // Front Panel settings power etc?
 // Banks and VFO?
 
+// Features Required
+// Default AMS and Memory name (in mem extras) to enabled. 
+
 // Bugs
 // MYCALL and Opening Message errors if not 10 characters
 // Values greater than one sometimes stored as whole bytes, these need to be refactored into bit fields
@@ -74,7 +74,7 @@
 // Password setting on radio allows letters (DTMF), but letters cannot be entered at the radio's password prompt?  
 // 49 SCM.WTH Set the memory scan frequency range. ALL / BAND Defaults to ALL Not Band as stated in the manual. 
     
-    #seekto 0x049a;
+   #seekto 0x049a;
     struct { 
     u8 unknown0:4,
     squelch:4;              // Squelch F, Monitor, Dial Adjust the Squelch level
@@ -84,7 +84,7 @@
     struct { 
     u8 unknown:3,
     scan_resume:5;          // 52 SCN.RSM   Configure the scan stop mode settings. 2.0 S - 5.0 S - 10.0 S / BUSY / HOLD
-    u8 unknown1:3 
+    u8 unknown1:3, 
     dw_resume_interval:5;   // 22 DW RSM    Configure the scan stop mode settings for Dual Receive. 2.0S-10.0S/BUSY/HOLD
     u8 unknown2;          
     u8 unknown3:3,
@@ -93,8 +93,8 @@
     gm_ring:2;              // 24 GM RNG    Select the beep option while receiving digital GM info. OFF/IN RNG/ALWAYS 
     u8 temp_cf;             // Placeholder as not found                        
     u8 unknown5;
-    } first_settings;    
-    
+    } first_settings;   
+   
     #seekto 0x04ed;
     struct {   
     u8 unknown1:1,
@@ -113,72 +113,64 @@
     beep_level:3;           // 05 BEP.LVL   Beep volume setting LEVEL1 - LEVEL4 - LEVEL7
     u8 unknown2:6,
     beep_select:2;          // 04 BEEP      Sets the beep sound function OFF / KEY+SC / KEY
-    } beep_settings;          
-                
+    } beep_settings;        
+    
     #seekto 0x04ce;                     
     struct {
-    u8 unknown:5,
-    lcd_dimmer:3;           // 14 DIMMER    LCD Dimmer LEVEL1 - LEVEL6
-    u8 unknown0:5,
-    dtmf_delay:3;           // 18 DT DLY    DTMF delay 50MS / 250MS / 450MS / 750MS / 1000MS  
-    u8 unknown01[4];     
+    u8 lcd_dimmer;                      // 14 DIMMER    LCD Dimmer
+    u8 dtmf_delay;                      // 18 DT DLY    DTMF delay    
+    u8 unknown0[3];             
     u8 unknown1:4,
-    lamp:4;                 // 28 LAMP      Time backlight and keys lit. OFF/2 SEC-10 SEC/CONT
-    u8 unknown1a:5,
-    lock:3;                 // 30 LOCK      Configure the lock mode setting. KEY/DIAL/K+D/PTT/K+P/D+P/ALL
+    unknown1:4;      
+    u8 lamp;                            // 28 LAMP      Set the duration time of the backlight and keys to be lit
+    u8 lock;                            // 30 LOCK      Configure the lock mode setting. KEY/DIAL/K+D/PTT/K+P/D+P/ALL
     u8 unknown2_1;
-    u8 unknown2a:4,
-    mic_gain:4;             // 31 MCGAIN    Adjust the microphone gain level. LEVEL1 - LEVEL5 - LEVEL9
+    u8 mic_gain;                        // 31 MCGAIN    Adjust the microphone gain level
     u8 unknown2_3;
-    u8 unknown2_4:3,
-    dw_interval:5;          // 21 DW INT    Set priority memory channel monitoring int during Dual Receive. 0.1S-10.0S
-    u8 unknown2_5:5,
-    ptt_delay:3;            // 42 PTT.DLY   Set PTT delay time. OFF / 20 MS / 50 MS / 100 MS / 200 MS              
-    u8 unknown2_5:2,
-    rx_save:6;              // 48 RX.SAVE   Set the battery save time. OFF / 0.2 S - 60.0 S    
-    u8 unknown2_6:3,
-    scan_restart:5;         // 53 SCN.STR   Set the scanning restart time.  0.1 S - 2.0 S - 10.0 S    
-    u8 unknown2_7;         
-    u8 unknown2_8;         
+    u8 dw_interval;                     // 21 DW INT Set the priority memory channel monitoring interval during Dual Receive. 0.1S - 5.0S - 10.0S
+    u8 ptt_delay;                       // 42 PTT.DLY   Set the PTT delay time. OFF / 20 MS / 50 MS / 100 MS / 200 MS
+    u8 rx_save;                         // 48 RX.SAVE   Set the battery save time. OFF / 0.2 S - 60.0 S    
+    u8 scan_restart;                    // 53 SCN.STR   Set the scanning restart time.  0.1 S - 2.0 S - 10.0 S
+    u8 unknown2_5;                      
+    u8 unknown2_6;          
     u8 unknown4[5];
-    u8 unknown4_1:3,
-    tot:5;                  // 56 TOT       Set the transmission timeout timer 
-    u8 unknown5[3];         // 26                                                
-    u8 vfo_mode:1,          // 60 VFO.MOD   Set the frequency setting range in the VFO mode by DIAL knob. ALL / BAND
+    u8 tot;                             // 56 TOT       Set the transmission timeout timer 
+    u8 unknown5[3];          // 26                                                
+    u8 vfo_mode:1,                      // 60 VFO.MOD   Set the frequency setting range in the VFO mode by DIAL knob. ALL / BAND
     unknown7:1,
-    scan_lamp:1,            // 51 SCN.LMP   Set the scan lamp ON or OFF when scanning stops On/Off
+    scan_lamp:1,                        // 51 SCN.LMP   Set the scan lamp ON or OFF when scanning stops On/Off
     unknown8:1,
-    ars:1,                  // 45 RPT.ARS   Turn the ARS function on/off.
-    dtmf_speed:1,           // 20 DT SPD    Set DTMF speed
-    unknown8:1,             
-    dtmf_mode:1;            // DTMF Mode set from front panel
-    u8 busy_led:1,          // Not Supported ?  
+    ars:1,                              // 45 RPT.ARS   Turn the ARS function on/off.
+    dtmf_speed:1,                       // 20 DT SPD    Set DTMF speed
+    unknown8:1,                        
+    dtmf_mode:1;                        // DTMF Mode set from front panel
+    u8 busy_led:1,                      // Not Supported ?  
     unknown8_2:1,
     unknown8_3:1,
-    bclo:1,                 // 03 BCLO      Turns the busy channel lockout function on/off.
-    beep_edge:1,            // 06 BEP.Edg   Sets the beep sound ON or OFF when a band edge is encountered.    
+    bclo:1,                             // 03 BCLO      Turns the busy channel lockout function on/off.
+    beep_edge:1,                        // 06 BEP.Edg   Sets the beep sound ON or OFF when a band edge is encountered.    
     unknown8_6:1, 
     unknown8_7:1,
-    unknown8_8:1;           // 28
+    unknown8_8:1;            // 28
     u8 unknown9_1:1,                   
     unknown9_2:1,
     unknown9_3:1,
     unknown9_4:1,         
     unknown9_5:1,             
-    password:1,             // Placeholder location
-    home_rev:1,             // 26 HOME/REV   Select the function of the [HOME/REV] key.
-    moni:1;                 // 32 Mon/T-Call Select the function of the [MONI/T-CALL] switch.
-    u8 gm_interval:4,       // 25 GM INT Set the transmission interval of digital GM information. LONG / NORMAL / OFF
+    password:1,                         // Placeholder location
+    home_rev:1,                         // 26 HOME/REV   Select the function of the [HOME/REV] key.
+    moni:1;                             // 32 Mon/T-Call Select the function of the [MONI/T-CALL] switch.
+    u8 gm_interval:4,       // 30       // 25 GM INT Set the transmission interval of digital GM information. OFF / NORMAL / LONG 
     unknown10:4;
     u8 unknown11;          
     u8 unknown12:1,
     unknown12_2:1,
     unknown12_3:1,
     unknown12_4:1,                
-    home_vfo:1,             // 27 HOME->VFO  Turn transfer VFO to the Home channel ON or OFF.
+    home_vfo:1,                         // 27 HOME->VFO  Turn transfer VFO to the Home channel ON or OFF.
     unknown12_6:1, 
     unknown12_7:1,
-    dw_rt:1;                // 23 DW RVT     Turn the "Priority Channel Revert" feature ON or OFF during Dual Receive.
+    dw_rt:1;                // 32       // 23 DW RVT     Turn the "Priority Channel Revert" feature ON or OFF during Dual Receive.
     u8 unknown33;
     u8 unknown34;
     u8 unknown35;
@@ -192,8 +184,8 @@
     u8 unknown43;
     u8 unknown44;
     u8 unknown45;
-    u8 prog_key1;            // P1 Set Mode Items to the Programmable Key
-    u8 prog_key2;            // P2 Set Mode Items to the Programmable Key
+    u8 prog_key1;           // P1 Set Mode Items to the Programmable Key
+    u8 prog_key2;           // P2 Set Mode Items to the Programmable Key
     u8 unknown48;
     u8 unknown49;
     u8 unknown50;                      
@@ -205,8 +197,8 @@
     unknown2:1,
     unknown3:1,
     unknown4:1,
-    vfo_scan_width:1,        // Placeholder as not found - 50 SCV.WTH Set the VFO scan frequency range. BAND / ALL 
-    memory_scan_width:1,     // Placeholder as not found - 49 SCM.WTH Set the memory scan frequency range. ALL / BAND 
+    vfo_scan_width:1,       // Placeholder as not found - 50 SCV.WTH Set the VFO scan frequency range. BAND / ALL 
+    memory_scan_width:1,    // Placeholder as not found - 49 SCM.WTH Set the memory scan frequency range. ALL / BAND 
     unknown7:1,
     unknown8:1;
     } scan_settings_1;
@@ -214,20 +206,22 @@
     #seekto 0x06B6;  
     struct {
     u8 unknown1:3,
-    volume:5;                // # VOL and Dial  Adjust the volume level
+    volume:5;               // # VOL and Dial  Adjust the volume level
     } scan_settings_2;       
-       
-    #seekto 0x0690;          // Memory or VFO Settings Map?
+        
+    #seekto 0x0690;         // Memory or VFO Settings Map?
     struct {
-    u8 unknown[64];
-    } vfo_info;
-        
-    #seekto 0x0710;          // Backup Memory or VFO Settings Map?
+    u8 unknown[48];         // Array cannot be 64 elements!
+    u8 unknown1[16];        // Exception: Not implemented for chirp.bitwise.structDataElement       
+    } vfo_info_1;
+    
+    #seekto 0x0710;         // Backup Memory or VFO Settings Map?
     struct {
-    u8 unknown[64];
-    } vfo_backup_info;       
+    u8 unknown[48];
+    u8 unknown1[16];
+    } vfo_backup_info_1;      
        
-    #seekto 0x064a;          // Unknown (From FT1D) For reference only
+    #seekto 0x064a;         // Unknown (From FT1D) For reference only
     struct {
     u8 unknown0[4];
     u8 frequency_band;
@@ -241,7 +235,7 @@
     u16 bank_enable;
     u8 unknown4[5];
     u8 unknown5:6,
-    power:2;
+    power:2;                // 3 - High, 2 - Mid, 1 - Low
     u8 unknown6:4,
     tune_step:4;
     u8 unknown7:6,
@@ -277,13 +271,11 @@
     u8 flag;
     u16 unknown2;
     struct {
-    char padded_string[6];   // 36 OPN.MSG   Select MSG then key vm to edit it
+    char padded_string[6];              // 36 OPN.MSG   Select MSG then key vm to edit it
     } message;
-    } opening_message;       // 36 OPN.MSG   Select the Opening Message when the transceiver is ON. OFF / MSG / DC    
+    } opening_message;                  // 36 OPN.MSG   Select the Opening Message when the transceiver is ON. OFF / MSG / DC    
  
-    // ^^^ All above U8's have been refactored to minimum number of bits  
- 
-    #seekto 0x094a;          // DTMF Memories
+    #seekto 0x094a;                     // DTMF Memories
     struct {
     u8 memory[16];
     } dtmf[10];    
@@ -301,7 +293,8 @@
     #seekto 0x0EFE;
     struct {
     u8 unknown[2];
-    u8 name[16];
+    u8 name[6];
+    u8 unknown1[10];
     } bank_info[24];
         
     #seekto 0xCF30;
@@ -313,66 +306,82 @@
     u8 unknown4;
     u8 unknown5;
     u8 unknown6;
-    u8 digital_popup;        // 15 DIG.POP   Call sign display pop up time                
+    u8 digital_popup;                   // 15 DIG.POP   Call sign display pop up time                
     } digital_settings_more;
-    
+   
     #seekto 0xCF7C;
     struct {
-    u8 ams_tx_mode;          // AMS TX Mode  Short Press AMS button AMS TX Mode
-    u8 unknown0;
-    u8 standby_beep;         // 07 BEP.STB   Standby Beep in the digital C4FM mode. On/Off
-    u8 unknown1; 
-    u8 unknown2;             
-    u8 unknown4;
-    u8 rx_dg_id;             // RX DG-ID     Long Press Mode Key, Mode Key to select, Dial
-    u8 tx_dg_id;             // TX DG-ID     Long Press Mode Key, Dial                  
-    u8 vw_mode;              // 16 DIG VW    Turn the VW mode selection ON or OFF
+    u8 unknown0:6,
+    ams_tx_mode:2;                      // AMS TX Mode  Short Press AMS button AMS TX Mode
+    u8 unknown1;
+    u8 unknown2:7,
+    standby_beep:1;                     // 07 BEP.STB   Standby Beep in the digital C4FM mode. On/Off
+    u8 unknown3; 
+    u8 unknown4:6,
+    gm_ring:2;                          // 24 GM RNG Select the beep option while receiving digital GM information. OFF / IN RNG /ALWAYS
+    u8 unknown5;
+    u8 rx_dg_id;                        // RX DG-ID     Long Press Mode Key, Mode Key to select, Dial
+    u8 tx_dg_id;                        // TX DG-ID     Long Press Mode Key, Dial                  
+    u8 unknown6:7,
+    vw_mode:1;                          // 16 DIG VW    Turn the VW mode selection ON or OFF
     u8 unknown7;
     } digital_settings;
+    
+    // ^^^ All above referenced U8's have been refactored to minimum number of bits.
+    
     """
 
 MEM_FORMAT = """
     #seekto 0x2D4A;
-    struct {                 // 32 Bytes per memory entry
-    u8 display_tag:1,        // 0 Display Freq, 1 Display Name
-    unknown0:1,              // Mode if AMS not selected???????? 
-    deviation:1,             // 0 Full deviation (Wide), 1 Half deviation (Narrow)
-    clock_shift:1,           // 0 None, 1 CPU clock shifted
-    unknown1:4;                                                              // 1
-    u8 mode:2,               // FM,AM,WFM only? - check
-    duplex:2,                // Works
-    tune_step:4;             // Works - check all steps? 7 = Auto            // 1
-    bbcd freq[3];            // Works                                        // 3
-    u8 power:2,              // Works
-    unknown2:1,              // 0 FM, 1 Digital - If AMS off     
-    ams:1,                   // 0 AMS off, 1 AMS on ?        
-    tone_mode:4;             // Works                                        // 1
-    u8 charsetbits[2];                                                       // 2    
-    char label[6];           // Works - Can only input 6 on screen           // 6
-    char unknown8[10];       // Rest of label ???                            // 10    
-    bbcd offset[3];          // Works                                        // 3
+    struct {                            // 32 Bytes per memory entry
+    u8 display_tag:1,                   // 0 Display Freq, 1 Display Name
+    unknown0:1,                         // Mode if AMS not selected???????? 
+    deviation:1,                        // 0 Full deviation (Wide), 1 Half deviation (Narrow)
+    clock_shift:1,                      // 0 None, 1 CPU clock shifted
+    unknown1:4;                                                                         // 1
+    u8 mode:2,                          // FM,AM,WFM only? - check
+    duplex:2,                           // Works
+    tune_step:4;                        // Works - check all steps? 7 = Auto            // 1
+    bbcd freq[3];                       // Works                                        // 3
+    u8 power:2,                         // Works
+    unknown2:1,                         // 0 FM, 1 Digital - If AMS off     
+    ams:1,                              // 0 AMS off, 1 AMS on ?        
+    tone_mode:4;                        // Works                                        // 1
+    u8 charsetbits[2];                                                                  // 2    
+    char label[6];                      // Works - Can only input 6 on screen           // 6
+    char unknown7[10];                  // Rest of label ???                            // 10    
+    bbcd offset[3];                     // Works                                        // 3
     u8 unknown5:2,
-    tone:6;                  // Works - check                                // 1
+    tone:6;                             // Works                                       // 1
     u8 unknown6:1,
-    dcs:7;                   // Works                                        // 1
-    u8 unknown7[3];                                                          // 3        
-    } memory[%d];
+    dcs:7;                              // Works                                        // 1
+    u8 unknown9;
+    u8 ams_on_dn_vw_fm:2,               // AMS DN, AMS VW, AMS FM  
+    unknown8_3:1,
+    unknown8_4:1,
+    unknown8_5:1,
+    unknown8_6:1,
+    unknown8_7:1,
+    unknown8_8:1;                   
+    u8 unknown10;                                                             
+    } memory[%d];                        // DN, VW, FM, AM 
+                                        // AMS DN, AMS VW, AMS FM  
     
     #seekto 0x280A;
     struct {
     u8 nosubvfo:1,
     unknown:3,
-    pskip:1,                 // PSkip (Select?)
-    skip:1,                  // Skip memory during scan
-    used:1,                  // Memory used 
-    valid:1;                 // Aways 1?
+    pskip:1,                            // PSkip (Select?)
+    skip:1,                             // Skip memory during scan
+    used:1,                             // Memory used 
+    valid:1;                            // Aways 1?
     } flag[%d];
     """
 
 MEM_CALLSIGN_FORMAT = """
 #seekto 0x0ced0;
     struct {
-    char padded_string[10];  // 63 MYCALL    Set the call sign. (up to 10 characters)
+    char padded_string[10];              // 63 MYCALL    Set the call sign. (up to 10 characters)
     } my_call;
     """
 
@@ -384,7 +393,8 @@
 TMODES = ["", "Tone", "TSQL", "DTCS"]
 DUPLEX = ["", "-", "+", "split"]
 
-MODES = ["FM", "AM", "NFM", "DIG", "Auto", "DV"]
+MODES = ["FM", "AM"]
+
 STEPS = [0, 5, 6.25, 10, 12.5, 15, 20, 25, 50, 100]  # 0 = auto
 RFSQUELCH = ["OFF", "S1", "S2", "S3", "S4", "S5", "S6", "S7", "S8"]
 
@@ -399,7 +409,7 @@
 
 POWER_LEVELS = [chirp_common.PowerLevel("Hi", watts=5.00),
                 chirp_common.PowerLevel("Mid", watts=2.00),
-                chirp_common.PowerLevel("Low", watts=0.50)]
+                chirp_common.PowerLevel("Low", watts=.50)]
 
 
 class FT70Bank(chirp_common.NamedBank):
@@ -547,7 +557,6 @@
     BAUD_RATE = 115200
     VENDOR = "Yaesu"
     MODEL = "FT-70D"
-    VARIANT = "E"
 
     _model = "AH51G"
 
@@ -717,7 +726,7 @@
         # We only speak english here in chirpville
         return [0x00, 0x00]
 
-    def _decode_power_level(self, mem):
+    def _decode_power_level(self, mem):             # 3 High 2 Mid 1 Low
         return POWER_LEVELS[3 - mem.power]
 
     def _encode_power_level(self, mem):
@@ -776,10 +785,11 @@
         self._set_mode(_mem, mem)
         _mem.dcs = chirp_common.DTCS_CODES.index(mem.dtcs)
         _mem.tune_step = STEPS.index(mem.tuning_step)
+
         if mem.power:
             _mem.power = self._encode_power_level(mem)
         else:
-            _mem.power = 0
+            _mem.power = 3  # Set 3 - High power as the default
 
         _mem.label = self._encode_label(mem)
         charsetbits = self._encode_charsetbits(mem)
@@ -790,7 +800,8 @@
 
         # Set Display Memory as Label bit`
         for element in mem.extra:
-            setattr(_mem, element.get_name(), element.value)
+            # setattr(_mem, element.get_name(), element.value)
+            setattr(_mem, element.get_name(), 1)
 
     @classmethod
     def _wipe_memory(cls, mem):
@@ -1067,7 +1078,7 @@
         rs = RadioSetting("scan_settings_2.volume", "Volume", val)
         menu.append(rs)
 
-        # Squelch F, Monitor, Dial Squelch Adjust the Squelch level
+        # Squelch       F key, Hold Monitor, Dial to adjust squelch level
 
         squelch_settings = self._memobj.squelch_settings
         val = RadioSettingValueList(
@@ -1076,7 +1087,14 @@
         rs = RadioSetting("squelch_settings.squelch", "Squelch", val)
         menu.append(rs)
 
-        # Power Level
+        # Power Level   F key, TX PO, Dial to adjust power level
+
+        # scan_settings_2 = self._memobj.scan_settings_2
+        # val = RadioSettingValueList(
+        #     self._VOLUME,
+        #     self._VOLUME[scan_settings_2.volume])
+        # rs = RadioSetting("scan_settings_2.volume", "Volume", val)
+        # menu.append(rs)
 
         return menu
 
@@ -1338,3 +1356,4 @@
         rawval = setting.value.get_value()
         val = 0 if cls._DIG_POP_UP.index(rawval) == 0 else cls._DIG_POP_UP.index(rawval) + 9
         obj.digital_popup = val
+
diff -r 8339092e3580 -r a1aea388f973 tox.ini
--- a/tox.ini	Sat Feb 17 17:33:30 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-[tox]
-envlist = unit,driver,style
-
-[testenv]
-basepython = python2.7
-sitepackages = True
-passenv = HOME
-whitelist_externals = bash
-
-[testenv:unit]
-deps =
-    nose
-commands =
-    nosetests -v tests/unit
-    python ./share/make_supported.py /dev/null
-
-[testenv:driver]
-commands =
-    python -munittest -vb tests
-
-[testenv:style]
-deps =
-    pep8==1.6.2
-commands =
-    python ./tools/cpep8.py
