pcb_calculator: Feature Calculation of voltage regulator with tolerances

This commit is contained in:
Jan Wichmann 2024-03-20 12:59:36 +00:00 committed by Wayne Stambaugh
parent 800ff9ffb1
commit 66d8f5cae4
14 changed files with 4922 additions and 2706 deletions

View File

@ -21,6 +21,7 @@
#include <wx/choicdlg.h>
#include <wx/filedlg.h>
#include <wx/msgdlg.h>
#include <wx/clipbrd.h>
#include <bitmaps.h>
#include <calculator_panels/panel_regulator.h>
@ -39,10 +40,6 @@ PANEL_REGULATOR::PANEL_REGULATOR( wxWindow* parent, wxWindowID id, const wxPoint
PANEL_REGULATOR_BASE( parent, id, pos, size, style, name ),
m_RegulatorListChanged( false )
{
m_IadjUnitLabel->SetLabel( wxT( "µA" ) );
m_r1Units->SetLabel( wxT( "kΩ" ) );
m_r2Units->SetLabel( wxT( "kΩ" ) );
m_bitmapRegul3pins->SetBitmap( KiBitmapBundle( BITMAPS::regul_3pins ) );
m_bitmapRegul4pins->SetBitmap( KiBitmapBundle( BITMAPS::regul ) );
@ -74,13 +71,33 @@ void PANEL_REGULATOR::OnRegulatorCalcButtonClick( wxCommandEvent& event )
void PANEL_REGULATOR::OnRegulatorResetButtonClick( wxCommandEvent& event )
{
m_RegulR1Value->SetValue( wxT( "10" ) );
m_RegulR2Value->SetValue( wxT( "10" ) );
m_RegulVrefValue->SetValue( wxT( "3" ) );
m_RegulVoutValue->SetValue( wxT( "12" ) );
m_choiceRegType->SetSelection( 0 );
m_rbRegulR1->SetValue( true );
m_rbRegulR2->SetValue( false );
m_resTolVal->SetValue( wxT( DEFAULT_REGULATOR_RESTOL ) );
m_r1MinVal->SetValue( wxT( "" ) );
m_r1TypVal->SetValue( wxT( DEFAULT_REGULATOR_R1 ) );
m_r1MaxVal->SetValue( wxT( "" ) );
m_r2MinVal->SetValue( wxT( "" ) );
m_r2TypVal->SetValue( wxT( DEFAULT_REGULATOR_R2 ) );
m_r2MaxVal->SetValue( wxT( "" ) );
m_vrefMinVal->SetValue( wxT( DEFAULT_REGULATOR_VREF_MIN ) );
m_vrefTypVal->SetValue( wxT( DEFAULT_REGULATOR_VREF_TYP ) );
m_vrefMaxVal->SetValue( wxT( DEFAULT_REGULATOR_VREF_MAX ) );
m_voutMinVal->SetValue( wxT( "" ) );
m_voutTypVal->SetValue( wxT( DEFAULT_REGULATOR_VOUT_TYP ) );
m_voutMaxVal->SetValue( wxT( "" ) );
m_iadjTypVal->SetValue( wxT( DEFAULT_REGULATOR_IADJ_TYP ) );
m_iadjMaxVal->SetValue( wxT( DEFAULT_REGULATOR_IADJ_MAX ) );
m_tolTotalMin->SetValue( wxT( "" ) );
m_TolTotalMax->SetValue( wxT( "" ) );
m_choiceRegType->SetSelection( 1 );
m_rbRegulR1->SetValue( false );
m_rbRegulR2->SetValue( true );
m_rbRegulVout->SetValue( false );
RegulatorPageUpdate();
}
@ -94,14 +111,24 @@ void PANEL_REGULATOR::RegulatorPageUpdate()
case 0:
m_bitmapRegul4pins->Show( true );
m_bitmapRegul3pins->Show( false );
m_RegulIadjValue->Enable( false );
m_RegulIadjTitle->Show( false );
m_iadjTypVal->Show( false );
m_iadjMaxVal->Show( false );
m_labelUnitsIadj->Show( false );
m_RegulFormula->SetLabel( wxT( "Vout = Vref * (R1 + R2) / R2" ) );
break;
case 1:
m_bitmapRegul4pins->Show( false );
m_bitmapRegul3pins->Show( true );
m_RegulIadjValue->Enable( true );
m_RegulIadjTitle->Show( true );
m_iadjTypVal->Show( true );
m_iadjMaxVal->Show( true );
m_labelUnitsIadj->Show( true );
m_RegulFormula->SetLabel( wxT( "Vout = Vref * (R1 + R2) / R1 + Iadj * R2" ) );
break;
}
@ -134,10 +161,19 @@ void PANEL_REGULATOR::OnRegulatorSelection( wxCommandEvent& event )
m_lastSelectedRegulatorName = item->m_Name;
m_choiceRegType->SetSelection( item->m_Type );
wxString value;
value.Printf( wxT( "%g" ), item->m_Vref );
m_RegulVrefValue->SetValue( value );
value.Printf( wxT( "%g" ), item->m_Iadj );
m_RegulIadjValue->SetValue( value );
value.Printf( wxT( "%g" ), item->m_VrefMin );
m_vrefMinVal->SetValue( value );
value.Printf( wxT( "%g" ), item->m_VrefTyp );
m_vrefTypVal->SetValue( value );
value.Printf( wxT( "%g" ), item->m_VrefMax );
m_vrefMaxVal->SetValue( value );
value.Printf( wxT( "%g" ), item->m_IadjTyp );
m_iadjTypVal->SetValue( value );
value.Printf( wxT( "%g" ), item->m_IadjMax );
m_iadjMaxVal->SetValue( value );
}
// Call RegulatorPageUpdate to enable/disable tools,
@ -156,8 +192,9 @@ void PANEL_REGULATOR::OnDataFileSelection( wxCommandEvent& event )
wxWindow* topLevelParent = wxGetTopLevelParent( this );
wxFileDialog dlg( topLevelParent, _( "Select PCB Calculator Data File" ),
wxEmptyString, fullfilename, wildcard, wxFD_OPEN );
// Must be wxFD_SAVE, otherwise you cannot assign a file name
wxFileDialog dlg( topLevelParent, _( "Select PCB Calculator Data File" ), wxEmptyString,
fullfilename, wildcard, wxFD_SAVE );
if( dlg.ShowModal() == wxID_CANCEL )
return;
@ -171,8 +208,9 @@ void PANEL_REGULATOR::OnDataFileSelection( wxCommandEvent& event )
if( wxFileExists( fullfilename ) && m_RegulatorList.GetCount() > 0 ) // Read file
{
if( wxMessageBox( _( "Do you want to load this file and replace current regulator list?" ) )
!= wxID_OK )
if( wxMessageBox( _( "Do you want to load this file and replace current regulator list?" ),
wxASCII_STR( wxMessageBoxCaptionStr ), wxOK | wxCANCEL | wxCENTER, this )
!= wxOK )
{
return;
}
@ -288,6 +326,18 @@ void PANEL_REGULATOR::SelectLastSelectedRegulator()
}
void PANEL_REGULATOR::OnCopyCB( wxCommandEvent& event )
{
if( wxTheClipboard->Open() )
{
// This data objects are held by the clipboard,
// so do not delete them in the app.
wxTheClipboard->SetData( new wxTextDataObject( m_textPowerComment->GetValue() ) );
wxTheClipboard->Close();
}
}
void PANEL_REGULATOR::RegulatorsSolve()
{
int id;
@ -310,7 +360,12 @@ void PANEL_REGULATOR::RegulatorsSolve()
return;
}
double r1, r2, vref, vout;
double restol;
double r1min, r1typ, r1max;
double r2min, r2typ, r2max;
double vrefmin, vreftyp, vrefmax;
double voutmin, vouttyp, voutmax, voutnom;
double toltotalmin, toltotalmax;
wxString txt;
@ -321,29 +376,46 @@ void PANEL_REGULATOR::RegulatorsSolve()
int r2scale = 1000;
// Read values from panel:
txt = m_RegulR1Value->GetValue();
r1 = DoubleFromString( txt ) * r1scale;
txt = m_RegulR2Value->GetValue();
r2 = DoubleFromString( txt ) * r2scale;
txt = m_RegulVrefValue->GetValue();
vref = DoubleFromString( txt );
txt = m_RegulVoutValue->GetValue();
vout = DoubleFromString( txt );
txt = m_resTolVal->GetValue();
restol = DoubleFromString( txt ) / 100;
txt = m_r1TypVal->GetValue();
r1typ = DoubleFromString( txt ) * r1scale;
txt = m_r2TypVal->GetValue();
r2typ = DoubleFromString( txt ) * r2scale;
txt = m_vrefMinVal->GetValue();
vrefmin = DoubleFromString( txt );
txt = m_vrefTypVal->GetValue();
vreftyp = DoubleFromString( txt );
txt = m_vrefMaxVal->GetValue();
vrefmax = DoubleFromString( txt );
txt = m_voutTypVal->GetValue();
vouttyp = DoubleFromString( txt );
voutnom = vouttyp;
// Some tests:
if( vout < vref && id != 2 )
if( ( vouttyp < vrefmin || vouttyp < vreftyp || vouttyp < vrefmax ) && id != 2 )
{
m_RegulMessage->SetLabel( _( "Vout must be greater than vref" ) );
return;
}
if( vref == 0.0 )
if( vrefmin == 0.0 || vreftyp == 0.0 || vrefmax == 0.0 )
{
m_RegulMessage->SetLabel( _( "Vref set to 0 !" ) );
return;
}
if( ( r1 < 0 && id != 0 ) || ( r2 <= 0 && id != 1 ) )
if( vrefmin > vreftyp || vreftyp > vrefmax )
{
m_RegulMessage->SetLabel( _( "Vref must VrefMin < VrefTyp < VrefMax" ) );
return;
}
if( ( r1typ < 0 && id != 0 ) || ( r2typ <= 0 && id != 1 ) )
{
m_RegulMessage->SetLabel( _( "Incorrect value for R1 R2" ) );
return;
@ -353,81 +425,136 @@ void PANEL_REGULATOR::RegulatorsSolve()
if( m_choiceRegType->GetSelection() == 1)
{
// 3 terminal regulator
txt = m_RegulIadjValue->GetValue();
double iadj = DoubleFromString( txt );
txt = m_iadjTypVal->GetValue();
double iadjtyp = DoubleFromString( txt );
txt = m_iadjMaxVal->GetValue();
double iadjmax = DoubleFromString( txt );
if( iadjtyp > iadjmax )
{
m_RegulMessage->SetLabel( _( "Iadj must IadjTyp < IadjMax" ) );
return;
}
// iadj is given in micro amp, so convert it in amp.
iadj /= 1000000;
iadjtyp /= 1000000;
iadjmax /= 1000000;
switch( id )
{
case 0:
r1 = vref * r2 / ( vout - vref - ( r2 * iadj ) );
// typical formula
r1typ = vreftyp * r2typ / ( vouttyp - vreftyp - ( r2typ * iadjtyp ) );
break;
case 1:
r2 = ( vout - vref ) / ( iadj + ( vref / r1 ) );
// typical formula
r2typ = ( vouttyp - vreftyp ) / ( iadjtyp + ( vreftyp / r1typ ) );
break;
case 2:
vout = vref * ( r1 + r2 ) / r1;
vout += r2 * iadj;
// typical formula
vouttyp = vreftyp * ( r1typ + r2typ ) / r1typ;
voutnom = vouttyp;
vouttyp += r2typ * iadjtyp;
break;
}
r1min = r1typ - r1typ * restol;
r1max = r1typ + r1typ * restol;
r2min = r2typ - r2typ * restol;
r2max = r2typ + r2typ * restol;
voutmin = vrefmin * ( r1max + r2min ) / r1max;
voutmin += r2min * iadjtyp;
voutmax = vrefmax * ( r1min + r2max ) / r1min;
voutmax += r2typ * iadjmax;
}
else
{ // Standard 4 terminal regulator
switch( id )
{
case 0: r1 = ( vout / vref - 1 ) * r2; break;
case 1: r2 = r1 / ( vout / vref - 1 ); break;
case 2: vout = vref * ( r1 + r2 ) / r2; break;
}
}
case 0:
// typical formula
r1typ = ( vouttyp / vreftyp - 1 ) * r2typ;
break;
// write values to panel:
txt.Printf( wxT( "%g" ), r1 / r1scale );
m_RegulR1Value->SetValue( txt );
txt.Printf( wxT( "%g" ), r2 / r2scale );
m_RegulR2Value->SetValue( txt );
txt.Printf( wxT( "%g" ), vref );
m_RegulVrefValue->SetValue( txt );
txt.Printf( wxT( "%g" ), vout );
m_RegulVoutValue->SetValue( txt );
}
case 1:
// typical formula
r2typ = r1typ / ( vouttyp / vreftyp - 1 );
break;
void PANEL_REGULATOR::Regulators_WriteConfig( PCB_CALCULATOR_SETTINGS* aCfg )
{
// Save current parameter values in config.
aCfg->m_Regulators.r1 = m_RegulR1Value->GetValue();
aCfg->m_Regulators.r2 = m_RegulR2Value->GetValue();
aCfg->m_Regulators.vref = m_RegulVrefValue->GetValue();
aCfg->m_Regulators.vout = m_RegulVoutValue->GetValue();
aCfg->m_Regulators.data_file = GetDataFilename();
aCfg->m_Regulators.selected_regulator = m_lastSelectedRegulatorName;
aCfg->m_Regulators.type = m_choiceRegType->GetSelection();
// Store the parameter selection that was recently calculated (R1, R2 or Vout)
wxRadioButton* regprms[3] = { m_rbRegulR1, m_rbRegulR2, m_rbRegulVout };
for( int ii = 0; ii < 3; ii++ )
{
if( regprms[ii]->GetValue() )
{
aCfg->m_Regulators.last_param = ii;
case 2:
// typical formula
vouttyp = vreftyp * ( r1typ + r2typ ) / r2typ;
voutnom = vouttyp;
break;
}
r1min = r1typ - r1typ * restol;
r1max = r1typ + r1typ * restol;
r2min = r2typ - r2typ * restol;
r2max = r2typ + r2typ * restol;
voutmin = vrefmin * ( r1min + r2max ) / r2max;
voutmax = vrefmax * ( r1max + r2min ) / r2min;
}
toltotalmin = voutmin / voutnom * 100.0 - 100.0;
toltotalmax = voutmax / voutnom * 100.0 - 100.0;
// write values to panel:
txt.Printf( wxT( "%g" ), round_to( r1min / r1scale ) );
m_r1MinVal->SetValue( txt );
txt.Printf( wxT( "%g" ), round_to( r1typ / r1scale ) );
m_r1TypVal->SetValue( txt );
txt.Printf( wxT( "%g" ), round_to( r1max / r1scale ) );
m_r1MaxVal->SetValue( txt );
txt.Printf( wxT( "%g" ), round_to( r2min / r2scale ) );
m_r2MinVal->SetValue( txt );
txt.Printf( wxT( "%g" ), round_to( r2typ / r2scale ) );
m_r2TypVal->SetValue( txt );
txt.Printf( wxT( "%g" ), round_to( r2max / r2scale ) );
m_r2MaxVal->SetValue( txt );
txt.Printf( wxT( "%g" ), round_to( voutmin ) );
m_voutMinVal->SetValue( txt );
txt.Printf( wxT( "%g" ), round_to( vouttyp ) );
m_voutTypVal->SetValue( txt );
txt.Printf( wxT( "%g" ), round_to( voutmax ) );
m_voutMaxVal->SetValue( txt );
txt.Printf( wxT( "%g" ), round_to( toltotalmin, 0.01 ) );
m_tolTotalMin->SetValue( txt );
txt.Printf( wxT( "%g" ), round_to( toltotalmax, 0.01 ) );
m_TolTotalMax->SetValue( txt );
txt = wxString::Format( "%gV [%gV .. %gV]", round_to( vouttyp, 0.01 ),
round_to( voutmin, 0.01 ), round_to( voutmax, 0.01 ) );
m_textPowerComment->SetValue( txt );
}
void PANEL_REGULATOR::LoadSettings( PCB_CALCULATOR_SETTINGS* aCfg )
{
m_RegulR1Value->SetValue( aCfg->m_Regulators.r1 );
m_RegulR2Value->SetValue( aCfg->m_Regulators.r2 );
m_RegulVrefValue->SetValue( aCfg->m_Regulators.vref );
m_RegulVoutValue->SetValue( aCfg->m_Regulators.vout );
m_resTolVal->SetValue( aCfg->m_Regulators.resTol );
m_r1TypVal->SetValue( aCfg->m_Regulators.r1 );
m_r2TypVal->SetValue( aCfg->m_Regulators.r2 );
m_vrefMinVal->SetValue( aCfg->m_Regulators.vrefMin );
m_vrefTypVal->SetValue( aCfg->m_Regulators.vrefTyp );
m_vrefMaxVal->SetValue( aCfg->m_Regulators.vrefMax );
m_voutTypVal->SetValue( aCfg->m_Regulators.voutTyp );
m_iadjTypVal->SetValue( aCfg->m_Regulators.iadjTyp );
m_iadjMaxVal->SetValue( aCfg->m_Regulators.iadjMax );
SetDataFilename( aCfg->m_Regulators.data_file );
m_lastSelectedRegulatorName = aCfg->m_Regulators.selected_regulator;
m_choiceRegType->SetSelection( aCfg->m_Regulators.type );
@ -439,15 +566,27 @@ void PANEL_REGULATOR::LoadSettings( PCB_CALCULATOR_SETTINGS* aCfg )
for( int ii = 0; ii < 3; ii++ )
regprms[ii]->SetValue( aCfg->m_Regulators.last_param == ii );
RegulatorPageUpdate();
}
void PANEL_REGULATOR::SaveSettings( PCB_CALCULATOR_SETTINGS *aCfg )
{
aCfg->m_Regulators.r1 = m_RegulR1Value->GetValue();
aCfg->m_Regulators.r2 = m_RegulR2Value->GetValue();
aCfg->m_Regulators.vref = m_RegulVrefValue->GetValue();
m_RegulVoutValue->SetValue( aCfg->m_Regulators.vout );
aCfg->m_Regulators.resTol = m_resTolVal->GetValue();
aCfg->m_Regulators.r1 = m_r1TypVal->GetValue();
aCfg->m_Regulators.r2 = m_r2TypVal->GetValue();
aCfg->m_Regulators.vrefMin = m_vrefMinVal->GetValue();
aCfg->m_Regulators.vrefTyp = m_vrefTypVal->GetValue();
aCfg->m_Regulators.vrefMax = m_vrefMaxVal->GetValue();
m_voutTypVal->SetValue( aCfg->m_Regulators.voutTyp );
aCfg->m_Regulators.iadjTyp = m_iadjTypVal->GetValue();
aCfg->m_Regulators.iadjMax = m_iadjMaxVal->GetValue();
aCfg->m_Regulators.data_file = GetDataFilename();
aCfg->m_Regulators.selected_regulator = m_lastSelectedRegulatorName;
aCfg->m_Regulators.type = m_choiceRegType->GetSelection();
@ -491,3 +630,8 @@ void PANEL_REGULATOR::SetDataFilename( const wxString& aFilename )
m_regulators_fileNameCtrl->SetValue( fn.GetFullPath() );
}
}
double PANEL_REGULATOR::round_to( double value, double precision )
{
return std::round( value / precision ) * precision;
}

View File

@ -42,6 +42,7 @@ public:
void OnAddRegulator( wxCommandEvent& event ) override;
void OnEditRegulator( wxCommandEvent& event ) override;
void OnRemoveRegulator( wxCommandEvent& event ) override;
void OnCopyCB( wxCommandEvent& event ) override;
// Methods from CALCULATOR_PANEL that must be overridden
void LoadSettings( PCB_CALCULATOR_SETTINGS* aCfg ) override;
@ -62,13 +63,6 @@ public:
void RegulatorsSolve();
/**
* Write regulators parameters in configuration.
*
* @param aCfg is the configuration settings.
*/
void Regulators_WriteConfig( PCB_CALCULATOR_SETTINGS* aCfg );
/**
* @return the full filename of the selected pcb_calculator data file
*/
@ -86,6 +80,8 @@ public:
bool ReadDataFile();
bool WriteDataFile();
static double round_to( double value, double precision = 0.001 );
public:
REGULATOR_LIST m_RegulatorList; // the list of known regulators
wxString m_lastSelectedRegulatorName;

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf-dirty)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -129,39 +129,80 @@ PANEL_REGULATOR_BASE::PANEL_REGULATOR_BASE( wxWindow* parent, wxWindowID id, con
bSizer9->Add( 0, 10, 1, wxEXPAND, 5 );
wxFlexGridSizer* fgSizerRegParams;
fgSizerRegParams = new wxFlexGridSizer( 6, 4, 4, 0 );
fgSizerRegParams->AddGrowableCol( 2 );
fgSizerRegParams = new wxFlexGridSizer( 7, 6, 4, 0 );
fgSizerRegParams->AddGrowableCol( 1 );
fgSizerRegParams->SetFlexibleDirection( wxBOTH );
fgSizerRegParams->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
fgSizerRegParams->Add( 0, 0, 1, wxEXPAND, 5 );
fgSizerRegParams->Add( 0, 0, 1, wxEXPAND, 5 );
m_labelValMin = new wxStaticText( this, wxID_ANY, _("min"), wxDefaultPosition, wxDefaultSize, 0 );
m_labelValMin->Wrap( -1 );
fgSizerRegParams->Add( m_labelValMin, 0, wxALIGN_CENTER|wxALL, 5 );
m_labelValTyp = new wxStaticText( this, wxID_ANY, _("typ"), wxDefaultPosition, wxDefaultSize, 0 );
m_labelValTyp->Wrap( -1 );
fgSizerRegParams->Add( m_labelValTyp, 0, wxALIGN_CENTER|wxALL, 5 );
m_labelValMax = new wxStaticText( this, wxID_ANY, _("max"), wxDefaultPosition, wxDefaultSize, 0 );
m_labelValMax->Wrap( -1 );
fgSizerRegParams->Add( m_labelValMax, 0, wxALIGN_CENTER|wxALL, 5 );
fgSizerRegParams->Add( 0, 0, 1, wxEXPAND, 5 );
m_rbRegulR1 = new wxRadioButton( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
m_rbRegulR1->SetValue( true );
fgSizerRegParams->Add( m_rbRegulR1, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
m_labelRegultR1 = new wxStaticText( this, wxID_ANY, _("R1:"), wxDefaultPosition, wxDefaultSize, 0 );
m_labelRegultR1->Wrap( -1 );
fgSizerRegParams->Add( m_labelRegultR1, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
m_RegulR1Value = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerRegParams->Add( m_RegulR1Value, 0, wxEXPAND|wxLEFT|wxRIGHT, 5 );
m_r1MinVal = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
m_r1MinVal->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) );
m_r1Units = new wxStaticText( this, wxID_ANY, _("kOhm"), wxDefaultPosition, wxDefaultSize, 0 );
m_r1Units->Wrap( -1 );
fgSizerRegParams->Add( m_r1Units, 0, wxALIGN_CENTER_VERTICAL, 5 );
fgSizerRegParams->Add( m_r1MinVal, 0, wxALL|wxEXPAND, 5 );
m_r1TypVal = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerRegParams->Add( m_r1TypVal, 0, wxALL|wxEXPAND, 5 );
m_r1MaxVal = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
m_r1MaxVal->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) );
fgSizerRegParams->Add( m_r1MaxVal, 0, wxALL|wxEXPAND, 5 );
m_labelUnitsR1 = new wxStaticText( this, wxID_ANY, _("kΩ"), wxDefaultPosition, wxDefaultSize, 0 );
m_labelUnitsR1->Wrap( -1 );
fgSizerRegParams->Add( m_labelUnitsR1, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_rbRegulR2 = new wxRadioButton( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_rbRegulR2->SetValue( true );
fgSizerRegParams->Add( m_rbRegulR2, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
m_labelRegultR2 = new wxStaticText( this, wxID_ANY, _("R2:"), wxDefaultPosition, wxDefaultSize, 0 );
m_labelRegultR2->Wrap( -1 );
fgSizerRegParams->Add( m_labelRegultR2, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
m_RegulR2Value = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerRegParams->Add( m_RegulR2Value, 0, wxEXPAND|wxLEFT|wxRIGHT, 5 );
m_r2MinVal = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
m_r2MinVal->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) );
m_r2Units = new wxStaticText( this, wxID_ANY, _("kOhm"), wxDefaultPosition, wxDefaultSize, 0 );
m_r2Units->Wrap( -1 );
fgSizerRegParams->Add( m_r2Units, 0, wxALIGN_CENTER_VERTICAL, 5 );
fgSizerRegParams->Add( m_r2MinVal, 0, wxALL|wxEXPAND, 5 );
m_r2TypVal = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerRegParams->Add( m_r2TypVal, 0, wxALL|wxEXPAND, 5 );
m_r2MaxVal = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
m_r2MaxVal->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) );
fgSizerRegParams->Add( m_r2MaxVal, 0, wxALL|wxEXPAND, 5 );
m_labelUnitsR2 = new wxStaticText( this, wxID_ANY, _("kΩ"), wxDefaultPosition, wxDefaultSize, 0 );
m_labelUnitsR2->Wrap( -1 );
fgSizerRegParams->Add( m_labelUnitsR2, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_rbRegulVout = new wxRadioButton( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerRegParams->Add( m_rbRegulVout, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
@ -170,12 +211,22 @@ PANEL_REGULATOR_BASE::PANEL_REGULATOR_BASE( wxWindow* parent, wxWindowID id, con
m_labelVout->Wrap( -1 );
fgSizerRegParams->Add( m_labelVout, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
m_RegulVoutValue = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerRegParams->Add( m_RegulVoutValue, 0, wxEXPAND|wxLEFT|wxRIGHT, 5 );
m_voutMinVal = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
m_voutMinVal->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) );
m_unitsVout = new wxStaticText( this, wxID_ANY, _("V"), wxDefaultPosition, wxDefaultSize, 0 );
m_unitsVout->Wrap( -1 );
fgSizerRegParams->Add( m_unitsVout, 0, wxALIGN_CENTER_VERTICAL, 5 );
fgSizerRegParams->Add( m_voutMinVal, 0, wxALL|wxEXPAND, 5 );
m_voutTypVal = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerRegParams->Add( m_voutTypVal, 0, wxALL|wxEXPAND, 5 );
m_voutMaxVal = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
m_voutMaxVal->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) );
fgSizerRegParams->Add( m_voutMaxVal, 0, wxALL|wxEXPAND, 5 );
m_labelUnitsVout = new wxStaticText( this, wxID_ANY, _("V"), wxDefaultPosition, wxDefaultSize, 0 );
m_labelUnitsVout->Wrap( -1 );
fgSizerRegParams->Add( m_labelUnitsVout, 0, wxALIGN_CENTER_VERTICAL, 5 );
fgSizerRegParams->Add( 0, 0, 1, wxEXPAND, 5 );
@ -186,12 +237,18 @@ PANEL_REGULATOR_BASE::PANEL_REGULATOR_BASE( wxWindow* parent, wxWindowID id, con
fgSizerRegParams->Add( m_labelVRef, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
m_RegulVrefValue = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerRegParams->Add( m_RegulVrefValue, 0, wxEXPAND|wxLEFT|wxRIGHT, 5 );
m_vrefMinVal = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerRegParams->Add( m_vrefMinVal, 0, wxALL|wxEXPAND, 5 );
m_unitsVref = new wxStaticText( this, wxID_ANY, _("V"), wxDefaultPosition, wxDefaultSize, 0 );
m_unitsVref->Wrap( -1 );
fgSizerRegParams->Add( m_unitsVref, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_vrefTypVal = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerRegParams->Add( m_vrefTypVal, 0, wxALL|wxEXPAND, 5 );
m_vrefMaxVal = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerRegParams->Add( m_vrefMaxVal, 0, wxALL|wxEXPAND, 5 );
m_labelUnitsVref = new wxStaticText( this, wxID_ANY, _("V"), wxDefaultPosition, wxDefaultSize, 0 );
m_labelUnitsVref->Wrap( -1 );
fgSizerRegParams->Add( m_labelUnitsVref, 0, wxALIGN_CENTER_VERTICAL, 5 );
fgSizerRegParams->Add( 0, 0, 1, wxEXPAND, 5 );
@ -202,34 +259,108 @@ PANEL_REGULATOR_BASE::PANEL_REGULATOR_BASE( wxWindow* parent, wxWindowID id, con
fgSizerRegParams->Add( m_RegulIadjTitle, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
m_RegulIadjValue = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerRegParams->Add( m_RegulIadjValue, 0, wxEXPAND|wxLEFT|wxRIGHT, 5 );
m_IadjUnitLabel = new wxStaticText( this, wxID_ANY, _("uA"), wxDefaultPosition, wxDefaultSize, 0 );
m_IadjUnitLabel->Wrap( -1 );
fgSizerRegParams->Add( m_IadjUnitLabel, 0, wxALIGN_CENTER_VERTICAL, 5 );
fgSizerRegParams->Add( 0, 0, 1, wxEXPAND, 5 );
m_iadjTypVal = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerRegParams->Add( m_iadjTypVal, 0, wxALL|wxEXPAND, 5 );
m_iadjMaxVal = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerRegParams->Add( m_iadjMaxVal, 0, wxALL|wxEXPAND, 5 );
m_labelUnitsIadj = new wxStaticText( this, wxID_ANY, _("uA"), wxDefaultPosition, wxDefaultSize, 0 );
m_labelUnitsIadj->Wrap( -1 );
fgSizerRegParams->Add( m_labelUnitsIadj, 0, wxALIGN_CENTER_VERTICAL, 5 );
fgSizerRegParams->Add( 0, 0, 1, wxEXPAND, 5 );
m_labelTolSumary = new wxStaticText( this, wxID_ANY, _("Overall tolerance:"), wxDefaultPosition, wxDefaultSize, 0 );
m_labelTolSumary->Wrap( -1 );
fgSizerRegParams->Add( m_labelTolSumary, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_tolTotalMin = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
m_tolTotalMin->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) );
fgSizerRegParams->Add( m_tolTotalMin, 0, wxALL, 5 );
fgSizerRegParams->Add( 0, 0, 1, wxEXPAND, 5 );
m_TolTotalMax = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
m_TolTotalMax->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) );
fgSizerRegParams->Add( m_TolTotalMax, 0, wxALL, 5 );
m_labelTotalPercent = new wxStaticText( this, wxID_ANY, _("%"), wxDefaultPosition, wxDefaultSize, 0 );
m_labelTotalPercent->Wrap( -1 );
fgSizerRegParams->Add( m_labelTotalPercent, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
bSizer9->Add( fgSizerRegParams, 0, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 10 );
wxBoxSizer* bSizerResTol;
bSizerResTol = new wxBoxSizer( wxHORIZONTAL );
m_labelResTol = new wxStaticText( this, wxID_ANY, _("Resistor tolerance:"), wxDefaultPosition, wxSize( -1,-1 ), 0 );
m_labelResTol->Wrap( -1 );
bSizerResTol->Add( m_labelResTol, 0, wxALIGN_CENTER|wxALL, 5 );
bSizerResTol->Add( 0, 0, 1, 0, 5 );
m_resTolVal = new wxTextCtrl( this, wxID_ANY, _("1"), wxDefaultPosition, wxSize( 45,-1 ), 0 );
bSizerResTol->Add( m_resTolVal, 0, wxALIGN_CENTER|wxALL, 5 );
m_labelResTolUnit = new wxStaticText( this, wxID_ANY, _("%"), wxDefaultPosition, wxDefaultSize, 0 );
m_labelResTolUnit->Wrap( -1 );
bSizerResTol->Add( m_labelResTolUnit, 0, wxALIGN_CENTER|wxALL, 5 );
bSizer9->Add( bSizerResTol, 1, wxEXPAND|wxLEFT|wxRIGHT, 5 );
wxBoxSizer* bSizerComment;
bSizerComment = new wxBoxSizer( wxHORIZONTAL );
m_labelKicadComment = new wxStaticText( this, wxID_ANY, _("Power Comment:"), wxDefaultPosition, wxDefaultSize, 0 );
m_labelKicadComment->Wrap( -1 );
bSizerComment->Add( m_labelKicadComment, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_textPowerComment = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 200,-1 ), wxTE_CENTER|wxTE_READONLY );
m_textPowerComment->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) );
bSizerComment->Add( m_textPowerComment, 0, wxALL, 5 );
bSizerComment->Add( 0, 0, 1, wxEXPAND, 5 );
m_btCopyCB = new wxButton( this, wxID_ANY, _("Copy to Clipboard"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerComment->Add( m_btCopyCB, 0, wxALL, 5 );
bSizer9->Add( bSizerComment, 1, wxEXPAND|wxLEFT|wxRIGHT, 5 );
bSizerRegulRight->Add( bSizer9, 0, 0, 5 );
m_RegulMessage = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_RegulMessage->Wrap( -1 );
bSizerRegulRight->Add( m_RegulMessage, 0, wxALL|wxEXPAND, 10 );
wxBoxSizer* bSizerRegulButtonCalcReset;
bSizerRegulButtonCalcReset = new wxBoxSizer( wxHORIZONTAL );
m_buttonCalculate = new wxButton( this, wxID_ANY, _("Calculate"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonCalculate->SetMinSize( wxSize( 120,-1 ) );
bSizerRegulButtonCalcReset->Add( m_buttonCalculate, 0, wxTOP, 5 );
bSizerRegulButtonCalcReset->Add( m_buttonCalculate, 0, wxALL|wxTOP, 5 );
bSizerRegulButtonCalcReset->Add( 0, 0, 1, wxEXPAND, 5 );
bSizerRegulRight->Add( bSizerRegulButtonCalcReset, 0, wxEXPAND|wxLEFT, 5 );
m_RegulMessage = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_RegulMessage->Wrap( -1 );
bSizerRegulRight->Add( m_RegulMessage, 0, wxALL, 10 );
bSizerRegulRight->Add( 0, 0, 1, wxEXPAND, 5 );
@ -254,6 +385,7 @@ PANEL_REGULATOR_BASE::PANEL_REGULATOR_BASE( wxWindow* parent, wxWindowID id, con
m_buttonEditItem->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_REGULATOR_BASE::OnEditRegulator ), NULL, this );
m_buttonAddItem->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_REGULATOR_BASE::OnAddRegulator ), NULL, this );
m_buttonRemoveItem->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_REGULATOR_BASE::OnRemoveRegulator ), NULL, this );
m_btCopyCB->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_REGULATOR_BASE::OnCopyCB ), NULL, this );
m_buttonCalculate->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_REGULATOR_BASE::OnRegulatorCalcButtonClick ), NULL, this );
m_buttonRegulReset->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_REGULATOR_BASE::OnRegulatorResetButtonClick ), NULL, this );
}
@ -267,6 +399,7 @@ PANEL_REGULATOR_BASE::~PANEL_REGULATOR_BASE()
m_buttonEditItem->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_REGULATOR_BASE::OnEditRegulator ), NULL, this );
m_buttonAddItem->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_REGULATOR_BASE::OnAddRegulator ), NULL, this );
m_buttonRemoveItem->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_REGULATOR_BASE::OnRemoveRegulator ), NULL, this );
m_btCopyCB->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_REGULATOR_BASE::OnCopyCB ), NULL, this );
m_buttonCalculate->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_REGULATOR_BASE::OnRegulatorCalcButtonClick ), NULL, this );
m_buttonRegulReset->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_REGULATOR_BASE::OnRegulatorResetButtonClick ), NULL, this );

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf-dirty)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -52,26 +52,48 @@ class PANEL_REGULATOR_BASE : public CALCULATOR_PANEL
wxButton* m_buttonEditItem;
wxButton* m_buttonAddItem;
wxButton* m_buttonRemoveItem;
wxStaticText* m_labelValMin;
wxStaticText* m_labelValTyp;
wxStaticText* m_labelValMax;
wxRadioButton* m_rbRegulR1;
wxStaticText* m_labelRegultR1;
wxTextCtrl* m_RegulR1Value;
wxStaticText* m_r1Units;
wxTextCtrl* m_r1MinVal;
wxTextCtrl* m_r1TypVal;
wxTextCtrl* m_r1MaxVal;
wxStaticText* m_labelUnitsR1;
wxRadioButton* m_rbRegulR2;
wxStaticText* m_labelRegultR2;
wxTextCtrl* m_RegulR2Value;
wxStaticText* m_r2Units;
wxTextCtrl* m_r2MinVal;
wxTextCtrl* m_r2TypVal;
wxTextCtrl* m_r2MaxVal;
wxStaticText* m_labelUnitsR2;
wxRadioButton* m_rbRegulVout;
wxStaticText* m_labelVout;
wxTextCtrl* m_RegulVoutValue;
wxStaticText* m_unitsVout;
wxTextCtrl* m_voutMinVal;
wxTextCtrl* m_voutTypVal;
wxTextCtrl* m_voutMaxVal;
wxStaticText* m_labelUnitsVout;
wxStaticText* m_labelVRef;
wxTextCtrl* m_RegulVrefValue;
wxStaticText* m_unitsVref;
wxTextCtrl* m_vrefMinVal;
wxTextCtrl* m_vrefTypVal;
wxTextCtrl* m_vrefMaxVal;
wxStaticText* m_labelUnitsVref;
wxStaticText* m_RegulIadjTitle;
wxTextCtrl* m_RegulIadjValue;
wxStaticText* m_IadjUnitLabel;
wxButton* m_buttonCalculate;
wxTextCtrl* m_iadjTypVal;
wxTextCtrl* m_iadjMaxVal;
wxStaticText* m_labelUnitsIadj;
wxStaticText* m_labelTolSumary;
wxTextCtrl* m_tolTotalMin;
wxTextCtrl* m_TolTotalMax;
wxStaticText* m_labelTotalPercent;
wxStaticText* m_labelResTol;
wxTextCtrl* m_resTolVal;
wxStaticText* m_labelResTolUnit;
wxStaticText* m_labelKicadComment;
wxTextCtrl* m_textPowerComment;
wxButton* m_btCopyCB;
wxStaticText* m_RegulMessage;
wxButton* m_buttonCalculate;
wxButton* m_buttonRegulReset;
// Virtual event handlers, override them in your derived class
@ -81,6 +103,7 @@ class PANEL_REGULATOR_BASE : public CALCULATOR_PANEL
virtual void OnEditRegulator( wxCommandEvent& event ) { event.Skip(); }
virtual void OnAddRegulator( wxCommandEvent& event ) { event.Skip(); }
virtual void OnRemoveRegulator( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCopyCB( wxCommandEvent& event ) { event.Skip(); }
virtual void OnRegulatorCalcButtonClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnRegulatorResetButtonClick( wxCommandEvent& event ) { event.Skip(); }

View File

@ -40,11 +40,11 @@
class REGULATOR_DATA
{
public:
REGULATOR_DATA( const wxString& aName, double aVref, int aType, double aIadj = 0) :
REGULATOR_DATA( const wxString& aName, double aVrefMin, double aVrefTyp, double aVrefMax,
int aType, double aIadjTyp = 0, double aIadjMax = 0 ) :
m_Name( aName ),
m_Type( aType ),
m_Vref( aVref ),
m_Iadj( aIadj )
m_Type( aType ), m_VrefMin( aVrefMin ), m_VrefTyp( aVrefTyp ), m_VrefMax( aVrefMax ),
m_IadjTyp( aIadjTyp ), m_IadjMax( aIadjMax )
{
}
@ -52,8 +52,11 @@ public:
wxString m_Name; // Regulator name
int m_Type; // type: with separate sense pin (normal) (=0)
// or adjustable 3 pins reg (=1)
double m_Vref; // Vreference in volt
double m_Iadj; // 3 pin type only: I adjust in micro amp
double m_VrefMin; // min Vreference in volt
double m_VrefTyp; // typ Vreference in volt
double m_VrefMax; // max Vreference in volt
double m_IadjTyp; // 3 pin type only: typ I adjust in micro amp
double m_IadjMax; // 3 pin type only: max I adjust in micro amp
};
// Helper class to store the list of known regulators
@ -141,6 +144,8 @@ public:
return list;
}
void Clear() { m_List.clear(); }
std::vector <REGULATOR_DATA*> m_List;
};

View File

@ -55,6 +55,7 @@ bool PANEL_REGULATOR::ReadDataFile()
// Switch the locale to standard C (needed to read/write floating point numbers)
LOCALE_IO toggle;
m_RegulatorList.Clear();
PCB_CALCULATOR_DATAFILE* datafile = new PCB_CALCULATOR_DATAFILE( &m_RegulatorList );
@ -133,7 +134,7 @@ int PCB_CALCULATOR_DATAFILE::WriteHeader( OUTPUTFORMATTER* aFormatter ) const
{
int nestlevel = 0;
aFormatter->Print( nestlevel++, "(datafile\n");
aFormatter->Print( nestlevel++, "(version 1)\n" );
aFormatter->Print( nestlevel++, "(version 2)\n" );
aFormatter->Print( nestlevel++, "(date %s)\n",
aFormatter->Quotew( GetISO8601CurrentDateTime() ).c_str() );
aFormatter->Print( nestlevel++, "(tool %s)\n",
@ -152,14 +153,21 @@ void PCB_CALCULATOR_DATAFILE::Format( OUTPUTFORMATTER* aFormatter,
for( REGULATOR_DATA* item : m_list->m_List )
{
aFormatter->Print( aNestLevel, "(%s %s\n", getTokenName( T_regulator ),
aFormatter->Quotew(item->m_Name ).c_str() );
aFormatter->Print( aNestLevel+1, "(%s %g)\n", getTokenName( T_reg_vref ),
item->m_Vref );
aFormatter->Quotew( item->m_Name ).c_str() );
if( item->m_Iadj != 0 && item->m_Type == 1)
aFormatter->Print( aNestLevel + 1, "(%s %g)\n", getTokenName( T_reg_vref_min ),
item->m_VrefMin );
aFormatter->Print( aNestLevel + 1, "(%s %g)\n", getTokenName( T_reg_vref_typ ),
item->m_VrefTyp );
aFormatter->Print( aNestLevel + 1, "(%s %g)\n", getTokenName( T_reg_vref_max ),
item->m_VrefMax );
if( item->m_Type == 1 )
{
aFormatter->Print( aNestLevel+1, "(%s %g)\n", getTokenName( T_reg_iadj ),
item->m_Iadj );
aFormatter->Print( aNestLevel + 1, "(%s %g)\n", getTokenName( T_reg_iadj_typ ),
item->m_IadjTyp );
aFormatter->Print( aNestLevel + 1, "(%s %g)\n", getTokenName( T_reg_iadj_max ),
item->m_IadjMax );
}
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_reg_type ),
@ -214,7 +222,22 @@ void PCB_CALCULATOR_DATAFILE_PARSER::ParseRegulatorDescr( PCB_CALCULATOR_DATAFIL
{
T token;
wxString name;
double vref, iadj;
double vrefmin, vreftyp, vrefmax = 0.0;
double iadjtyp, iadjmax = 0.0;
auto parseToken = [&]()
{
double val;
token = NextTok();
if( token != T_NUMBER )
Expecting( T_NUMBER );
sscanf( CurText(), "%lf", &val );
NeedRIGHT();
return val;
};
int type;
while( ( token = NextTok() ) != T_RIGHT )
@ -228,7 +251,11 @@ void PCB_CALCULATOR_DATAFILE_PARSER::ParseRegulatorDescr( PCB_CALCULATOR_DATAFIL
if( token == T_regulator )
{
type = 0;
vref = 0.0;
vrefmin = 0.0;
vreftyp = 0.0;
vrefmax = 0.0;
iadjtyp = 0.0;
iadjmax = 0.0;
// Read name
token = NextTok();
@ -244,26 +271,26 @@ void PCB_CALCULATOR_DATAFILE_PARSER::ParseRegulatorDescr( PCB_CALCULATOR_DATAFIL
switch( token )
{
case T_reg_vref: // the voltage reference value
token = NextTok();
if( token != T_NUMBER )
Expecting( T_NUMBER );
sscanf( CurText(), "%lf" , &vref);
NeedRIGHT();
// Parse legacy entry
case T_reg_vref:
vreftyp = parseToken();
vrefmin = vreftyp;
vrefmax = vreftyp;
break;
case T_reg_iadj: // the Iadj reference value
token = NextTok();
case T_reg_vref_min: vrefmin = parseToken(); break;
case T_reg_vref_typ: vreftyp = parseToken(); break;
case T_reg_vref_max: vrefmax = parseToken(); break;
if( token != T_NUMBER )
Expecting( T_NUMBER );
sscanf( CurText(), "%lf" , &iadj);
NeedRIGHT();
// Parse legacy entry
case T_reg_iadj:
iadjtyp = parseToken();
iadjmax = iadjtyp;
break;
case T_reg_iadj_typ: iadjtyp = parseToken(); break;
case T_reg_iadj_max: iadjmax = parseToken(); break;
case T_reg_type: // type: normal or 3 terminal reg
token = NextTok();
@ -285,10 +312,8 @@ void PCB_CALCULATOR_DATAFILE_PARSER::ParseRegulatorDescr( PCB_CALCULATOR_DATAFIL
if( ! name.IsEmpty() )
{
if( type != 1 )
iadj = 0.0;
REGULATOR_DATA* new_item = new REGULATOR_DATA( name, vref, type, iadj );
REGULATOR_DATA* new_item = new REGULATOR_DATA( name, vrefmin, vreftyp, vrefmax,
type, iadjtyp, iadjmax );
aDataList->m_list->Add( new_item );
}
}

View File

@ -48,6 +48,9 @@ DIALOG_REGULATOR_FORM::~DIALOG_REGULATOR_FORM()
bool DIALOG_REGULATOR_FORM::TransferDataFromWindow()
{
wxTextCtrl* vref_values[] = { m_vrefMinVal, m_vrefTypVal, m_vrefMaxVal };
wxTextCtrl* iadj_values[] = { m_iadjTypVal, m_iadjMaxVal };
if( !wxDialog::TransferDataFromWindow() )
return false;
@ -56,23 +59,39 @@ bool DIALOG_REGULATOR_FORM::TransferDataFromWindow()
if( m_textCtrlName->GetValue().IsEmpty() )
success = false;
if( m_textCtrlVref->GetValue().IsEmpty() )
for( const auto& val : vref_values )
{
if( val->GetValue().IsEmpty() )
{
success = false;
}
else
{
double vref = DoubleFromString( m_textCtrlVref->GetValue() );
double vref = DoubleFromString( val->GetValue() );
if( fabs( vref ) < 0.01 )
if( fabs( vref ) < 0.1 )
success = false;
}
}
if( m_choiceRegType->GetSelection() == 1 )
{
if( m_RegulIadjValue->GetValue().IsEmpty() )
for( const auto& val : iadj_values )
{
if( val->GetValue().IsEmpty() )
{
success = false;
}
else
{
int iadj = 0;
bool res = val->GetValue().ToInt( &iadj );
if( res == false || fabs( iadj ) < 1 )
success = false;
}
}
}
return success;
}
@ -81,7 +100,10 @@ bool DIALOG_REGULATOR_FORM::TransferDataFromWindow()
void DIALOG_REGULATOR_FORM::UpdateDialog()
{
bool enbl = m_choiceRegType->GetSelection() == 1;
m_RegulIadjValue->Enable( enbl );
m_RegulIadjTitle->Show( enbl );
m_iadjTypVal->Show( enbl );
m_iadjMaxVal->Show( enbl );
m_labelUnitIadj->Show( enbl );
}
@ -89,10 +111,19 @@ void DIALOG_REGULATOR_FORM::CopyRegulatorDataToDialog( REGULATOR_DATA* aItem )
{
m_textCtrlName->SetValue( aItem->m_Name );
wxString value;
value.Printf( wxT( "%g" ), aItem->m_Vref );
m_textCtrlVref->SetValue( value );
value.Printf( wxT( "%g" ), aItem->m_Iadj );
m_RegulIadjValue->SetValue( value );
value.Printf( wxT( "%.3g" ), aItem->m_VrefMin );
m_vrefMinVal->SetValue( value );
value.Printf( wxT( "%.3g" ), aItem->m_VrefTyp );
m_vrefTypVal->SetValue( value );
value.Printf( wxT( "%.3g" ), aItem->m_VrefMax );
m_vrefMaxVal->SetValue( value );
value.Printf( wxT( "%.3g" ), aItem->m_IadjTyp );
m_iadjTypVal->SetValue( value );
value.Printf( wxT( "%.3g" ), aItem->m_IadjMax );
m_iadjMaxVal->SetValue( value );
m_choiceRegType->SetSelection( aItem->m_Type );
UpdateDialog();
}
@ -100,13 +131,22 @@ void DIALOG_REGULATOR_FORM::CopyRegulatorDataToDialog( REGULATOR_DATA* aItem )
REGULATOR_DATA* DIALOG_REGULATOR_FORM::BuildRegulatorFromData()
{
double vref = DoubleFromString( m_textCtrlVref->GetValue() );
double iadj = DoubleFromString( m_RegulIadjValue->GetValue() );
double vrefmin = DoubleFromString( m_vrefMinVal->GetValue() );
double vreftyp = DoubleFromString( m_vrefTypVal->GetValue() );
double vrefmax = DoubleFromString( m_vrefMaxVal->GetValue() );
double iadjtyp = DoubleFromString( m_iadjTypVal->GetValue() );
double iadjmax = DoubleFromString( m_iadjMaxVal->GetValue() );
int type = m_choiceRegType->GetSelection();
if( type != 1 )
iadj = 0.0;
{
iadjtyp = 0.0;
iadjmax = 0.0;
}
REGULATOR_DATA* item = new REGULATOR_DATA( m_textCtrlName->GetValue(), vref, type, iadj );
REGULATOR_DATA* item = new REGULATOR_DATA( m_textCtrlName->GetValue(), vrefmin, vreftyp,
vrefmax, type, iadjtyp, iadjmax );
return item;
}

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -34,12 +34,24 @@ DIALOG_REGULATOR_FORM_BASE::DIALOG_REGULATOR_FORM_BASE( wxWindow* parent, wxWind
fgSizerPrms->Add( 0, 0, 1, wxEXPAND, 5 );
m_staticTextVref = new wxStaticText( this, wxID_ANY, _("Vref:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextVref = new wxStaticText( this, wxID_ANY, _("Vref (min/typ/max):"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextVref->Wrap( -1 );
fgSizerPrms->Add( m_staticTextVref, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_textCtrlVref = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerPrms->Add( m_textCtrlVref, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 );
wxBoxSizer* bSizer2;
bSizer2 = new wxBoxSizer( wxHORIZONTAL );
m_vrefMinVal = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizer2->Add( m_vrefMinVal, 0, wxALL, 5 );
m_vrefTypVal = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizer2->Add( m_vrefTypVal, 0, wxALL, 5 );
m_vrefMaxVal = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizer2->Add( m_vrefMaxVal, 0, wxALL, 5 );
fgSizerPrms->Add( bSizer2, 1, wxEXPAND, 5 );
m_staticTextVrefUnit = new wxStaticText( this, wxID_ANY, _("Volt"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextVrefUnit->Wrap( -1 );
@ -58,16 +70,28 @@ DIALOG_REGULATOR_FORM_BASE::DIALOG_REGULATOR_FORM_BASE( wxWindow* parent, wxWind
fgSizerPrms->Add( 0, 0, 1, wxEXPAND, 5 );
m_RegulIadjTitle = new wxStaticText( this, wxID_ANY, _("Iadj:"), wxDefaultPosition, wxDefaultSize, 0 );
m_RegulIadjTitle = new wxStaticText( this, wxID_ANY, _("Iadj (typ/max):"), wxDefaultPosition, wxDefaultSize, 0 );
m_RegulIadjTitle->Wrap( -1 );
fgSizerPrms->Add( m_RegulIadjTitle, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_RegulIadjValue = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerPrms->Add( m_RegulIadjValue, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 );
wxBoxSizer* bSizer3;
bSizer3 = new wxBoxSizer( wxHORIZONTAL );
m_IadjUnitLabel = new wxStaticText( this, wxID_ANY, _("uA"), wxDefaultPosition, wxDefaultSize, 0 );
m_IadjUnitLabel->Wrap( -1 );
fgSizerPrms->Add( m_IadjUnitLabel, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
bSizer3->Add( 0, 0, 1, 0, 5 );
m_iadjTypVal = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizer3->Add( m_iadjTypVal, 0, wxALL, 5 );
m_iadjMaxVal = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizer3->Add( m_iadjMaxVal, 0, wxALL, 5 );
fgSizerPrms->Add( bSizer3, 1, wxEXPAND, 5 );
m_labelUnitIadj = new wxStaticText( this, wxID_ANY, _("uA"), wxDefaultPosition, wxDefaultSize, 0 );
m_labelUnitIadj->Wrap( -1 );
fgSizerPrms->Add( m_labelUnitIadj, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
bSizerMain->Add( fgSizerPrms, 0, wxEXPAND, 5 );

View File

@ -244,7 +244,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Vref:</property>
<property name="label">Vref (min/typ/max):</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
@ -273,9 +273,18 @@
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer2</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="0">
<property name="BottomDockable">1</property>
@ -313,7 +322,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_textCtrlVref</property>
<property name="name">m_vrefMinVal</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -337,6 +346,136 @@
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_vrefTypVal</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_vrefMaxVal</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
@ -566,7 +705,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Iadj:</property>
<property name="label">Iadj (typ/max):</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
@ -595,9 +734,28 @@
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer3</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag"></property>
<property name="proportion">1</property>
<object class="spacer" expanded="1">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="0">
<property name="BottomDockable">1</property>
@ -635,7 +793,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_RegulIadjValue</property>
<property name="name">m_iadjTypVal</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -659,6 +817,72 @@
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_iadjMaxVal</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
@ -700,7 +924,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_IadjUnitLabel</property>
<property name="name">m_labelUnitIadj</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -18,8 +18,8 @@
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/choice.h>
#include <wx/sizer.h>
#include <wx/choice.h>
#include <wx/button.h>
#include <wx/dialog.h>
@ -37,13 +37,16 @@ class DIALOG_REGULATOR_FORM_BASE : public DIALOG_SHIM
wxStaticText* m_staticTextName;
wxTextCtrl* m_textCtrlName;
wxStaticText* m_staticTextVref;
wxTextCtrl* m_textCtrlVref;
wxTextCtrl* m_vrefMinVal;
wxTextCtrl* m_vrefTypVal;
wxTextCtrl* m_vrefMaxVal;
wxStaticText* m_staticTextVrefUnit;
wxStaticText* m_staticTextType;
wxChoice* m_choiceRegType;
wxStaticText* m_RegulIadjTitle;
wxTextCtrl* m_RegulIadjValue;
wxStaticText* m_IadjUnitLabel;
wxTextCtrl* m_iadjTypVal;
wxTextCtrl* m_iadjMaxVal;
wxStaticText* m_labelUnitIadj;
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel;

View File

@ -1,5 +1,10 @@
regulators
regulator
reg_iadj
reg_iadj_typ
reg_iadj_max
reg_vref
reg_vref_min
reg_vref_typ
reg_vref_max
reg_type

View File

@ -101,13 +101,29 @@ PCB_CALCULATOR_SETTINGS::PCB_CALCULATOR_SETTINGS() :
&m_Electrical.iec60664_altitude, 2000 ) );
// Regulators params
m_params.emplace_back( new PARAM<wxString>( "regulators.r1", &m_Regulators.r1, "10" ) );
m_params.emplace_back( new PARAM<wxString>( "regulators.resTol", &m_Regulators.resTol,
DEFAULT_REGULATOR_RESTOL ) );
m_params.emplace_back( new PARAM<wxString>( "regulators.r2", &m_Regulators.r2, "10" ) );
m_params.emplace_back(
new PARAM<wxString>( "regulators.r1", &m_Regulators.r1, DEFAULT_REGULATOR_R1 ) );
m_params.emplace_back( new PARAM<wxString>( "regulators.vref", &m_Regulators.vref, "3" ) );
m_params.emplace_back(
new PARAM<wxString>( "regulators.r2", &m_Regulators.r2, DEFAULT_REGULATOR_R2 ) );
m_params.emplace_back( new PARAM<wxString>( "regulators.vout", &m_Regulators.vout, "12" ) );
m_params.emplace_back( new PARAM<wxString>( "regulators.vrefMin", &m_Regulators.vrefMin,
DEFAULT_REGULATOR_VREF_MIN ) );
m_params.emplace_back( new PARAM<wxString>( "regulators.vrefTyp", &m_Regulators.vrefTyp,
DEFAULT_REGULATOR_VREF_TYP ) );
m_params.emplace_back( new PARAM<wxString>( "regulators.vrefMax", &m_Regulators.vrefMax,
DEFAULT_REGULATOR_VREF_MAX ) );
m_params.emplace_back( new PARAM<wxString>( "regulators.voutTyp", &m_Regulators.voutTyp,
DEFAULT_REGULATOR_VOUT_TYP ) );
m_params.emplace_back( new PARAM<wxString>( "regulators.iadjTyp", &m_Regulators.iadjTyp,
DEFAULT_REGULATOR_IADJ_TYP ) );
m_params.emplace_back( new PARAM<wxString>( "regulators.iadjMax", &m_Regulators.iadjMax,
DEFAULT_REGULATOR_IADJ_MAX ) );
m_params.emplace_back( new PARAM<wxString>( "regulators.data_file",
&m_Regulators.data_file, "" ) );
@ -115,7 +131,7 @@ PCB_CALCULATOR_SETTINGS::PCB_CALCULATOR_SETTINGS() :
m_params.emplace_back( new PARAM<wxString>( "regulators.selected_regulator",
&m_Regulators.selected_regulator, "" ) );
m_params.emplace_back( new PARAM<int>( "regulators.type", &m_Regulators.type, 0 ) );
m_params.emplace_back( new PARAM<int>( "regulators.type", &m_Regulators.type, 1 ) );
m_params.emplace_back( new PARAM<int>( "regulators.last_param", &m_Regulators.last_param, 0 ) );

View File

@ -28,6 +28,17 @@
#include <unordered_map>
#include <settings/app_settings.h>
// Deafult value for TI LM317
#define DEFAULT_REGULATOR_RESTOL "1"
#define DEFAULT_REGULATOR_R1 "0.240"
#define DEFAULT_REGULATOR_R2 "0.720"
#define DEFAULT_REGULATOR_VREF_MIN "1.20"
#define DEFAULT_REGULATOR_VREF_TYP "1.25"
#define DEFAULT_REGULATOR_VREF_MAX "1.30"
#define DEFAULT_REGULATOR_VOUT_TYP "5"
#define DEFAULT_REGULATOR_IADJ_TYP "50"
#define DEFAULT_REGULATOR_IADJ_MAX "100"
class PCB_CALCULATOR_SETTINGS : public APP_SETTINGS_BASE
{
public:
@ -63,10 +74,15 @@ public:
struct REGULATORS
{
wxString resTol;
wxString r1;
wxString r2;
wxString vref;
wxString vout;
wxString vrefMin;
wxString vrefTyp;
wxString vrefMax;
wxString voutTyp;
wxString iadjTyp;
wxString iadjMax;
wxString data_file;
wxString selected_regulator;
int type;