Skip to content

Commit

Permalink
gps ui
Browse files Browse the repository at this point in the history
  • Loading branch information
ic005k committed Feb 12, 2025
1 parent e285ab3 commit 80c833d
Show file tree
Hide file tree
Showing 8 changed files with 535 additions and 755 deletions.
38 changes: 28 additions & 10 deletions android/src/com/x/MyActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,10 @@ public class MyActivity
private Location previousLocation;
private double previousAltitude;

private String strGpsStatus = "None";
private String strGpsStatus = "GPS Status";
private String strRunTime = "Run Time";
private String strAltitude = "Altitude";
private String strTotalDistance = "Total Distance";
private String strTotalDistance = "Run Distance";
private String strMaxSpeed = "Max Speed";
private String strTotalClimb = "Total Climb";
private String strAverageSpeed = "Average Speed";
Expand Down Expand Up @@ -760,8 +760,8 @@ public void onGpsStatusChanged(int event) {
};

public String getGpsStatus() {
return strTotalDistance + " " + strRunTime + "\n" + strAverageSpeed + " " + strMaxSpeed + "\n" + strAltitude
+ " " + strTotalClimb + "\n" + strGpsStatus;
return strTotalDistance + "\n" + strRunTime + "\n" + strAverageSpeed + "\n" + strMaxSpeed + "\n" + strAltitude
+ "\n" + strTotalClimb + "\n" + strGpsStatus;
}

public double startGpsUpdates() {
Expand Down Expand Up @@ -912,24 +912,42 @@ private void updateTrackingData(Location currentLocation) {

private void updateUI(Location location) {
// 运动距离
strTotalDistance = String.format("距离: %.2f km", totalDistance);
if (zh_cn)
strTotalDistance = String.format("距离: %.2f km", totalDistance);
else
strTotalDistance = String.format("Distance: %.2f km", totalDistance);

// 运动时间
long seconds = movingTime / 1000;
strRunTime = String.format("时间: %02d:%02d:%02d", seconds / 3600, (seconds % 3600) / 60, seconds % 60);
if (zh_cn)
strRunTime = String.format("运动时长: %02d:%02d:%02d", seconds / 3600, (seconds % 3600) / 60, seconds % 60);
else
strRunTime = String.format("Run Time: %02d:%02d:%02d", seconds / 3600, (seconds % 3600) / 60, seconds % 60);

// 平均速度
double avgSpeed = totalDistance / (movingTime / 3600000f);
strAverageSpeed = String.format("平均速度: %.2f km/h", avgSpeed);
if (zh_cn)
strAverageSpeed = String.format("平均速度: %.2f km/h", avgSpeed);
else
strAverageSpeed = String.format("Average Speed: %.2f km/h", avgSpeed);

// 最大速度
strMaxSpeed = String.format("最大速度: %.2f km/h", maxSpeed);
if (zh_cn)
strMaxSpeed = String.format("最大速度: %.2f km/h", maxSpeed);
else
strMaxSpeed = String.format("Max Speed: %.2f km/h", maxSpeed);

// 海拔
strAltitude = String.format("海拔: %.2f 米", location.getAltitude());
if (zh_cn)
strAltitude = String.format("海拔: %.2f 米", location.getAltitude());
else
strAltitude = String.format("Altitude: %.2f 米", location.getAltitude());

// 爬升
strTotalClimb = String.format("爬升: %.2f 米", totalClimb);
if (zh_cn)
strTotalClimb = String.format("爬升: %.2f 米", totalClimb);
else
strTotalClimb = String.format("Total Climb: %.2f 米", totalClimb);
}

private static ServiceConnection mCon = new ServiceConnection() {
Expand Down
87 changes: 6 additions & 81 deletions src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,12 +399,10 @@ void MainWindow::initHardStepSensor() {
ui->btnPause->click();
ui->btnPause->setHidden(true);
ui->btnSteps->setHidden(true);
if (ui->rbAlg1->isChecked()) m_Steps->on_rbAlg1_clicked();
}
if (isHardStepSensor == 1) {
ui->btnPause->click();
ui->gboxAlg->hide();
ui->lblAlg->hide();

ui->lblSteps->hide();
ui->btnPauseSteps->hide();
ui->lblTotalRunTime->hide();
Expand Down Expand Up @@ -455,71 +453,6 @@ void MainWindow::initTodayInitSteps() {
}
}

void MainWindow::newDatas() {
ax = ay = az = gx = gy = gz = 0;
az = accel_pedometer->reading()->z();

updateRunTime();

countOne++;
if (ui->rbAlg1->isChecked()) {
if (countOne >= 2) {
aoldZ = az;
countOne = 0;
}
}

if (qAbs(qAbs(az) - qAbs(aoldZ)) < 0.5) {
return;
}

if (ui->rbAlg1->isChecked()) {
accel_pedometer->runStepCountAlgorithm();
timeCount++;
ui->lblSteps->setText(tr("Number of Operations") + " : " +
QString::number(timeCount));
}

showSensorValues();
}

void MainWindow::showSensorValues() {
if (m_Preferences->ui->chkDebug->isChecked()) {
ui->lblX->setText("AX:" + QString::number(ax) + "\n" +
"GX:" + QString::number(gx));
ui->lblY->setText("AY:" + QString::number(ay) + "\n" +
"GY:" + QString::number(gy));
ui->lblZ->setText("AZ:" + QString::number(az) + "\n" +
"GZ:" + QString::number(gz));

if (ui->lblX->isHidden()) {
ui->lblX->show();
ui->lblY->show();
ui->lblZ->show();
}
} else {
if (!ui->lblX->isHidden()) {
ui->lblX->hide();
ui->lblY->hide();
ui->lblZ->hide();
}
}
}

void MainWindow::updateRunTime() {
smallCount++;
if (ui->rbAlg1->isChecked()) {
if (smallCount >= 5) {
timeTest++;
smallCount = 0;
pausePedometer();
}
}

ui->lblTotalRunTime->setText(tr("Total Working Hours") + " : " +
secondsToTime(timeTest));
}

void MainWindow::pausePedometer() {
if (QTime::currentTime().toString("hh-mm-ss") == "22-00-00") {
if (ui->btnPauseSteps->text() == tr("Pause")) ui->btnPauseSteps->click();
Expand All @@ -528,12 +461,11 @@ void MainWindow::pausePedometer() {

void MainWindow::updateSteps() {
// CurrentSteps = accel_pedometer->stepCount();
if (ui->rbAlg1->isChecked()) {
CurrentSteps++;
CurTableCount = m_Steps->getCurrentSteps();
CurTableCount++;
m_Steps->toDayInitSteps++;
}

CurrentSteps++;
CurTableCount = m_Steps->getCurrentSteps();
CurTableCount++;
m_Steps->toDayInitSteps++;

ui->lcdNumber->display(QString::number(CurTableCount));
ui->lblSingle->setText(QString::number(CurrentSteps));
Expand Down Expand Up @@ -3424,16 +3356,9 @@ QString MainWindow::decMemos(QString strDec, QString file) {
void MainWindow::init_Sensors() {
accel_pedometer = new SpecialAccelerometerPedometer(this);

// connect(accel_pedometer, SIGNAL(readingChanged()), this,
// SLOT(newDatas()));

connect(accel_pedometer, SIGNAL(stepCountChanged()), this,
SLOT(updateSteps()));

accel_pedometer->setTangentLineIntercept(
ui->editTangentLineIntercept->text().toFloat());
accel_pedometer->setTangentLineSlope(
ui->editTangentLineSlope->text().toFloat());
accel_pedometer->setDataRate(100);
accel_pedometer->setAccelerationMode(QAccelerometer::User);
accel_pedometer->setAlwaysOn(true);
Expand Down
4 changes: 1 addition & 3 deletions src/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ class MainWindow : public QMainWindow {
void clickMainTab();
void on_SetReaderFunVisible();
void updateSteps();
void newDatas();

void updateHardSensorSteps();
void on_btnTodo_clicked();
void readEBookDone();
Expand Down Expand Up @@ -823,8 +823,6 @@ class MainWindow : public QMainWindow {
void init_UIWidget();
void init_Menu(QMenu *);

void updateRunTime();
void showSensorValues();
QString decMemos(QString strDec, QString file);
void initHardStepSensor();
void showNotes();
Expand Down
Loading

0 comments on commit 80c833d

Please sign in to comment.