21#include <wx/choicdlg.h> 
   22#include <wx/filedlg.h> 
   24#include <wx/clipbrd.h> 
   39                                  const wxSize& size, 
long style, 
const wxString& 
name ) :
 
   50    GetSizer()->SetSizeHints( 
this );
 
 
  120        m_RegulFormula->SetLabel( wxT( 
"Vout = Vref * (R1 + R2) / R2" ) );
 
  132        m_RegulFormula->SetLabel( wxT( 
"Vout = Vref * (R1 + R2) / R1 + Iadj * R2" ) );
 
  137    GetSizer()->Layout();
 
 
  165        value.Printf( wxT( 
"%g" ), item->
m_VrefMin );
 
  167        value.Printf( wxT( 
"%g" ), item->
m_VrefTyp );
 
  169        value.Printf( wxT( 
"%g" ), item->
m_VrefMax );
 
  172        value.Printf( wxT( 
"%g" ), item->
m_IadjTyp );
 
  175        value.Printf( wxT( 
"%g" ), item->
m_IadjMax );
 
 
  190    wildcard.Printf( 
_( 
"PCB Calculator data file" ) + wxT( 
" (*.%s)|*.%s" ),
 
  193    wxWindow* topLevelParent = wxGetTopLevelParent( 
this );
 
  196    wxFileDialog dlg( topLevelParent, 
_( 
"Select PCB Calculator Data File" ), wxEmptyString,
 
  197                      fullfilename, wildcard, wxFD_SAVE );
 
  199    if( dlg.ShowModal() == wxID_CANCEL )
 
  202    fullfilename = dlg.GetPath();
 
  211        if( wxMessageBox( 
_( 
"Do you want to load this file and replace current regulator list?" ),
 
  212                          wxASCII_STR( wxMessageBoxCaptionStr ), wxOK | wxCANCEL | wxCENTER, 
this )
 
  229        msg.Printf( 
_( 
"Unable to read data file '%s'." ), fullfilename );
 
 
  257        wxMessageBox( 
_( 
"This regulator is already in list. Aborted" ) );
 
 
  268    if( item == 
nullptr )
 
 
  289    wxString 
name = wxGetSingleChoice( 
_( 
"Remove Regulator" ), wxEmptyString,
 
 
  324    wxCommandEvent event;
 
 
  331    if( wxTheClipboard->Open() )
 
  336        wxTheClipboard->Close();
 
 
  359        wxMessageBox( wxT(
"Selection error" ) );
 
  364    double r1min, r1typ, r1max;
 
  365    double r2min, r2typ, r2max;
 
  366    double vrefmin, vreftyp, vrefmax;
 
  367    double voutmin, vouttyp, voutmax;
 
  368    double toltotalmin, toltotalmax;
 
  399    if( ( vouttyp < vrefmin || vouttyp < vreftyp || vouttyp < vrefmax ) && 
id != 2 )
 
  405    if( vrefmin == 0.0 || vreftyp == 0.0 || vrefmax == 0.0 )
 
  411    if( vrefmin > vreftyp || vreftyp > vrefmax )
 
  413        m_RegulMessage->SetLabel( 
_( 
"Vref must VrefMin < VrefTyp < VrefMax" ) );
 
  417    if( ( r1typ < 0 && 
id != 0 ) || ( r2typ <= 0 && 
id != 1 ) )
 
  432        if( iadjtyp > iadjmax )
 
  446            r1typ = vreftyp * r2typ / ( vouttyp - vreftyp - ( r2typ * iadjtyp ) );
 
  451            r2typ = ( vouttyp - vreftyp ) / ( iadjtyp + ( vreftyp / r1typ ) );
 
  456            vouttyp = vreftyp * ( r1typ + r2typ ) / r1typ;
 
  457            vouttyp += r2typ * iadjtyp;
 
  461        r1min = r1typ - r1typ * restol;
 
  462        r1max = r1typ + r1typ * restol;
 
  464        r2min = r2typ - r2typ * restol;
 
  465        r2max = r2typ + r2typ * restol;
 
  467        voutmin = vrefmin * ( r1max + r2min ) / r1max;
 
  468        voutmin += r2min * iadjtyp;
 
  470        voutmax = vrefmax * ( r1min + r2max ) / r1min;
 
  471        voutmax += r2max * iadjmax;
 
  479            r1typ = ( vouttyp / vreftyp - 1 ) * r2typ;
 
  484            r2typ = r1typ / ( vouttyp / vreftyp - 1 );
 
  489            vouttyp = vreftyp * ( r1typ + r2typ ) / r2typ;
 
  493        r1min = r1typ - r1typ * restol;
 
  494        r1max = r1typ + r1typ * restol;
 
  496        r2min = r2typ - r2typ * restol;
 
  497        r2max = r2typ + r2typ * restol;
 
  499        voutmin = vrefmin * ( r1min + r2max ) / r2max;
 
  500        voutmax = vrefmax * ( r1max + r2min ) / r2min;
 
  503    toltotalmin = ( voutmin - vouttyp ) / vouttyp * 100.0;
 
  504    toltotalmax = ( voutmax - vouttyp ) / voutmax * 100.0;
 
  507    txt.Printf( wxT( 
"%g" ), 
round_to( r1min / r1scale ) );
 
  509    txt.Printf( wxT( 
"%g" ), 
round_to( r1typ / r1scale ) );
 
  511    txt.Printf( wxT( 
"%g" ), 
round_to( r1max / r1scale ) );
 
  514    txt.Printf( wxT( 
"%g" ), 
round_to( r2min / r2scale ) );
 
  516    txt.Printf( wxT( 
"%g" ), 
round_to( r2typ / r2scale ) );
 
  518    txt.Printf( wxT( 
"%g" ), 
round_to( r2max / r2scale ) );
 
  521    txt.Printf( wxT( 
"%g" ), 
round_to( voutmin ) );
 
  523    txt.Printf( wxT( 
"%g" ), 
round_to( vouttyp ) );
 
  525    txt.Printf( wxT( 
"%g" ), 
round_to( voutmax ) );
 
  528    txt.Printf( wxT( 
"%g" ), 
round_to( toltotalmin, 0.01 ) );
 
  530    txt.Printf( wxT( 
"%g" ), 
round_to( toltotalmax, 0.01 ) );
 
  533    txt = wxString::Format( 
"%gV [%gV ... %gV]", 
round_to( vouttyp, 0.01 ),
 
 
  564    for( 
int ii = 0; ii < 3; ii++ )
 
 
  595    for( 
int ii = 0; ii < 3; ii++ )
 
  597        if( regprms[ii]->GetValue() )
 
 
  609        return wxEmptyString;
 
  613    return fn.GetFullPath();
 
 
  619    if( aFilename.IsEmpty() )
 
  625        wxFileName fn( aFilename );
 
 
  633    return std::round( value / precision ) * precision;
 
 
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
 
wxStaticText * m_RegulFormula
 
wxButton * m_buttonEditItem
 
wxTextCtrl * m_textPowerComment
 
wxTextCtrl * m_voutTypVal
 
wxTextCtrl * m_voutMinVal
 
wxStaticText * m_RegulMessage
 
wxTextCtrl * m_TolTotalMax
 
wxButton * m_buttonRemoveItem
 
wxTextCtrl * m_vrefMaxVal
 
wxChoice * m_choiceRegType
 
wxTextCtrl * m_iadjMaxVal
 
wxStaticText * m_RegulIadjTitle
 
wxTextCtrl * m_regulators_fileNameCtrl
 
wxTextCtrl * m_tolTotalMin
 
wxTextCtrl * m_voutMaxVal
 
wxRadioButton * m_rbRegulVout
 
wxStaticBitmap * m_bitmapRegul4pins
 
wxTextCtrl * m_iadjTypVal
 
wxChoice * m_choiceRegulatorSelector
 
wxStaticBitmap * m_bitmapRegul3pins
 
wxTextCtrl * m_vrefTypVal
 
wxStaticText * m_labelUnitsIadj
 
wxTextCtrl * m_vrefMinVal
 
wxRadioButton * m_rbRegulR2
 
wxRadioButton * m_rbRegulR1
 
PANEL_REGULATOR_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
 
void OnEditRegulator(wxCommandEvent &event) override
 
bool m_RegulatorListChanged
 
void OnRegulatorSelection(wxCommandEvent &event) override
 
static double round_to(double value, double precision=0.001)
 
void OnRegulatorResetButtonClick(wxCommandEvent &event) override
 
REGULATOR_LIST m_RegulatorList
 
void ThemeChanged() override
Update UI elements of the panel when the theme changes to ensure the images and fonts/colors are appr...
 
const wxString GetDataFilename()
 
void OnRegulatorCalcButtonClick(wxCommandEvent &event) override
 
void OnDataFileSelection(wxCommandEvent &event) override
 
void SetDataFilename(const wxString &aFilename)
Initialize the full filename of the selected pcb_calculator data file force the standard extension of...
 
void SelectLastSelectedRegulator()
If m_lastSelectedRegulatorName is empty, just calls RegulatorPageUpdate()
 
void OnRegulTypeSelection(wxCommandEvent &event) override
 
void OnCopyCB(wxCommandEvent &event) override
 
void SaveSettings(PCB_CALCULATOR_SETTINGS *aCfg) override
Save the settings from the panel.
 
void OnRemoveRegulator(wxCommandEvent &event) override
 
wxString m_lastSelectedRegulatorName
 
void OnAddRegulator(wxCommandEvent &event) override
 
PANEL_REGULATOR(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
 
void LoadSettings(PCB_CALCULATOR_SETTINGS *aCfg) override
Load the settings into the panel.
 
void RegulatorPageUpdate()
Update the regulator page dialog display.
 
Contains structures for storage of regulator data.
 
double DoubleFromString(const wxString &TextValue)
 
double DoubleFromString(const wxString &TextValue)
 
const wxString DataFileNameExt
 
#define DEFAULT_REGULATOR_RESTOL
 
#define DEFAULT_REGULATOR_IADJ_MAX
 
#define DEFAULT_REGULATOR_IADJ_TYP
 
#define DEFAULT_REGULATOR_R2
 
#define DEFAULT_REGULATOR_R1
 
#define DEFAULT_REGULATOR_VREF_TYP
 
#define DEFAULT_REGULATOR_VREF_MIN
 
#define DEFAULT_REGULATOR_VREF_MAX
 
#define DEFAULT_REGULATOR_VOUT_TYP
 
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
 
wxString selected_regulator