ตั้งค่าซอฟต์แวร์ทดสอบ

การประเมินฮาร์ดแวร์ใช้ซอฟต์แวร์ต่อไปนี้

  • Audacity (ติดตั้งใน PC)
  • MATLAB (ติดตั้งใน PC)
  • แอปทดสอบการโต้ตอบการสัมผัส (ติดตั้งใน DUT)

ดูข้อมูลเพิ่มเติมเกี่ยวกับข้อกำหนดของระบบได้ที่ Audacity สำหรับ Windows, Audacity สำหรับ Mac และ MATLAB

ตั้งค่า Audacity

คุณต้องตั้งค่า Audacity เพื่อรับอินพุตจากซาวด์การ์ด Sound Blaster ที่อัตราการสุ่มตัวอย่างข้อมูลหนึ่งๆ หลังจากเชื่อมต่อ Sound Blaster กับพอร์ต USB ของคอมพิวเตอร์แล้ว ให้เปิด Audacity แล้วทำตามวิธีการต่อไปนี้

  1. เลือกLine (USB Sound Blaster HD) เป็นแหล่งที่มาของไมโครโฟนอินพุต โดยเชื่อมต่อเอาต์พุต CCLD กับพอร์ตอินพุต Line In ของ Sound Blaster

    อินพุตไมโครโฟน

    รูปที่ 1 การเลือกอินพุตไมโครโฟน

  2. ตั้งค่าอัตราการสุ่มตัวอย่างเป็น 48 kHz โดยเลือก 48000 ในเมนูอัตรา โปรเจ็กต์

    อัตราการสุ่มตัวอย่าง

    รูปที่ 2 การตั้งค่าอัตราการสุ่มตัวอย่าง

ดาวน์โหลด MATLAB

  1. ดาวน์โหลดไฟล์ MATLAB

  2. แตกไฟล์แล้วค้นหา Effect1NEffect2_V1p0_2020PM.m (สำหรับ Effect1 และ Effect 2) และ Effect3_V1p0_2020PM.m (สำหรับ Effect 3)

ตั้งค่าแอปทดสอบในโทรศัพท์

ส่วนนี้จะอธิบายวิธีตั้งค่าแอปทดสอบในโทรศัพท์

เตรียมแอปทดสอบ

  1. คัดลอกซอร์สโค้ดจากบล็อกโค้ด Java และ Kotlin ด้านล่าง เลือกวิธีที่เหมาะกับคุณที่สุด
  2. เขียนโค้ดของคุณเองตามพารามิเตอร์ GUI ที่แสดงในรูปที่ 3 ปรับรายละเอียดของซอร์สโค้ดเลย์เอาต์ให้ตรงกับโทรศัพท์หากจำเป็น
  3. ตรวจสอบว่า GUI มีปุ่มที่คลิกได้ 3 ปุ่มและตัวบ่งชี้ภาพ เพื่อกำหนดพื้นที่ที่จะวางตัวตรวจวัดความเร่ง

    • พื้นที่สำหรับค้นหาตำแหน่งของเครื่องวัดความเร่งแสดงถึงพื้นที่จริงของหน้าจออุปกรณ์ที่มักจะสัมผัสด้วยมือ
    • ในระหว่างการวัดนี้ คุณสามารถย้ายมาตรความเร่งภายใน พื้นที่สีเขียวเทอร์ควอยส์เพื่อค้นหาพื้นที่ของหน้าจอที่จับ สัญญาณที่แรงที่สุด
  4. ติดตั้งโค้ดในอุปกรณ์ Android

  5. เราขอแนะนำอย่างยิ่งให้ตั้งค่าโหมดการนำทางของระบบเป็นโหมดท่าทางสัมผัส หากตั้งค่าโหมดเริ่มต้นเป็นปุ่ม

    • การตั้งค่าโหมดท่าทางสัมผัสจะช่วยให้คุณวางมาตรวัดความเร่งไว้ที่ด้านล่าง ของโทรศัพท์ได้มากที่สุดโดยไม่ถูกขัดจังหวะด้วย GUI การไปยังส่วนต่างๆ ของระบบ ของโทรศัพท์

ซอร์สโค้ด Java

package com.example.hapticeffectassessment;

import static android.os.VibrationEffect.EFFECT_CLICK;

import android.graphics.Color;
import android.os.Bundle;
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

 private static final long oneShotTiming = 20;
 private static final int oneShotAmplitude = 255;

 private static final long[] waveformTimings = {500, 500};
 private static final int[] waveformAmplitudes = {128, 255};

 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_main);

   Vibrator vibrator = getSystemService(Vibrator.class);

   // Click R.id.button1 button to generate Effect 1
   findViewById(R.id.button1).setOnClickListener(
       view -> vibrator.vibrate(VibrationEffect.createPredefined(EFFECT_CLICK)));

   // Click R.id.button2 button to generate Effect 2
   findViewById(R.id.button2).setOnClickListener(
       view -> vibrator.vibrate(VibrationEffect.createOneShot(oneShotTiming, oneShotAmplitude)));

   // Click R.id.button3 button to generate Effect 3
   findViewById(R.id.button3).setOnClickListener(view -> {
     vibrator.vibrate(VibrationEffect.createWaveform(waveformTimings, waveformAmplitudes, -1));

     // See quick results of Effect 3
     Button button = (Button) view;
     if (vibrator.hasAmplitudeControl()) {
       button.setText("Effect 3: PASS");
       button.setBackgroundColor(Color.GREEN);
       button.setTextColor(Color.BLACK);
     } else {
       button.setText("Effect 3: FAIL");
       button.setBackgroundColor(Color.RED);
       button.setTextColor(Color.WHITE);
     }
   });
 }
}

ซอร์สโค้ด Kotlin

package com.example.hapticeffectassessment

import android.graphics.Color
import android.os.Bundle
import android.os.VibrationEffect
import android.os.VibrationEffect.EFFECT_CLICK
import android.os.Vibrator
import android.widget.Button
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_main.*

class MainActivityKt : AppCompatActivity() {

 private val oneShotTiming: Long = 20
 private val oneShotAmplitude = 255

 private val waveformTimings = longArrayOf(500, 500)
 private val waveformAmplitudes = intArrayOf(128, 255)

 override fun onCreate(savedInstanceState: Bundle?) {
   super.onCreate(savedInstanceState)
   setContentView(R.layout.activity_main)

   val vibrator = getSystemService(Vibrator::class.java)

   // Click button1 to generate Effect 1
   button1.setOnClickListener {
     vibrator.vibrate(VibrationEffect.createPredefined(EFFECT_CLICK))
   }

   // Click button2 to generate Effect 2
   button2.setOnClickListener {
     vibrator.vibrate(VibrationEffect.createOneShot(oneShotTiming, oneShotAmplitude))
   }

   // Click button3 to generate Effect 3
   button3.setOnClickListener {
     vibrator.vibrate(
       VibrationEffect.createWaveform(waveformTimings, waveformAmplitudes, -1))

     // See quick results of Effect 3
     if (vibrator.hasAmplitudeControl()) {
       button3.text = "Effect 3: PASS"
       button3.setBackgroundColor(Color.GREEN)
       button3.setTextColor(Color.BLACK)
     } else {
       button3.text = "Effect 3: FAIL"
       button3.setBackgroundColor(Color.RED)
       button3.setTextColor(Color.WHITE)
     }
   }
 }
}

ซอร์สโค้ดเลย์เอาต์ (activity_main.xml)

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   tools:context=".MainActivity">

   <Button
       android:id="@+id/button1"
       android:layout_width="350dp"
       android:layout_height="60dp"
       android:layout_marginStart="32dp"
       android:layout_marginTop="5dp"
       android:layout_marginEnd="32dp"
       android:text="Effect 1"
       android:textSize="18sp"
       app:layout_constraintEnd_toEndOf="parent"
       app:layout_constraintStart_toStartOf="parent"
       app:layout_constraintTop_toTopOf="parent" />

   <Button
       android:id="@+id/button2"
       android:layout_width="350dp"
       android:layout_height="60dp"
       android:layout_marginStart="32dp"
       android:layout_marginTop="5dp"
       android:layout_marginEnd="32dp"
       android:text="Effect 2"
       android:textSize="18sp"
       app:layout_constraintEnd_toEndOf="parent"
       app:layout_constraintStart_toStartOf="parent"
       app:layout_constraintTop_toBottomOf="@+id/button1" />

   <Button
       android:id="@+id/button3"
       android:layout_width="350dp"
       android:layout_height="60dp"
       android:layout_marginStart="32dp"
       android:layout_marginTop="5dp"
       android:layout_marginEnd="32dp"
       android:text="Effect 3"
       android:textSize="18sp"
       app:layout_constraintEnd_toEndOf="parent"
       app:layout_constraintStart_toStartOf="parent"
       app:layout_constraintTop_toBottomOf="@+id/button2" />

   <View
       android:id="@+id/divider"
       android:layout_width="363dp"
       android:layout_height="1dp"
       android:layout_marginStart="32dp"
       android:layout_marginTop="10dp"
       android:layout_marginEnd="32dp"
       android:background="?android:attr/listDivider"
       app:layout_constraintEnd_toEndOf="parent"
       app:layout_constraintHorizontal_bias="0.5"
       app:layout_constraintStart_toStartOf="parent"
       app:layout_constraintTop_toBottomOf="@+id/button3" />

   <androidx.constraintlayout.widget.ConstraintLayout
       android:layout_width="363dp"
       android:layout_height="0dp"
       app:layout_constraintBottom_toBottomOf="parent"
       app:layout_constraintEnd_toEndOf="parent"
       app:layout_constraintHorizontal_bias="0.5"
       app:layout_constraintStart_toStartOf="parent"
       app:layout_constraintTop_toBottomOf="@+id/divider">

       <ImageView
           android:id="@+id/imageView"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:adjustViewBounds="true"
           android:scaleType="fitXY"
           app:layout_constraintBottom_toBottomOf="parent"
           app:layout_constraintEnd_toEndOf="parent"
           app:layout_constraintHorizontal_bias="0.5"
           app:layout_constraintStart_toStartOf="parent"
           app:layout_constraintTop_toTopOf="parent"
           app:srcCompat="@drawable/bluebar" />
   </androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

ตัวตรวจวัดความเร่ง

รูปที่ 3 ติดตัวตรวจวัดความเร่งตามพื้นที่ที่แนะนำใน GUI